Improve coverage in frontend and remove some dead code (#3031)

This commit is contained in:
Paul Melnikow
2019-02-22 00:08:11 -05:00
committed by GitHub
parent a9ed1e144e
commit cd49bda968
15 changed files with 179 additions and 17 deletions

View File

@@ -75,10 +75,6 @@ export default class BadgeExamples extends React.Component {
render() {
const { definitions } = this.props
if (!definitions) {
return null
}
const flattened = definitions.reduce((accum, current) => {
const { examples } = current
return accum.concat(examples)

View File

@@ -0,0 +1,126 @@
import React from 'react'
import { shallow } from 'enzyme'
import BadgeExamples from './badge-examples'
import '../enzyme-conf.spec'
const exampleServiceDefinitions = [
{
examples: [
{
title: 'Mozilla Add-on',
example: {
pattern: '/amo/d/:addonId',
namedParams: {
addonId: 'dustman',
},
queryParams: {},
},
preview: {
label: 'downloads',
message: '12k',
color: 'brightgreen',
},
keywords: ['amo', 'firefox'],
},
],
},
{
examples: [
{
title: 'Mozilla Add-on',
example: {
pattern: '/amo/rating/:addonId',
namedParams: {
addonId: 'dustman',
},
queryParams: {},
},
preview: {
label: 'rating',
message: '4/5',
color: 'brightgreen',
},
keywords: ['amo', 'firefox'],
},
{
title: 'Mozilla Add-on',
example: {
pattern: '/amo/stars/:addonId',
namedParams: {
addonId: 'dustman',
},
queryParams: {},
},
preview: {
label: 'stars',
message: '★★★★☆',
color: 'brightgreen',
},
keywords: ['amo', 'firefox'],
},
],
},
{
examples: [
{
title: 'Mozilla Add-on',
example: {
pattern: '/amo/users/:addonId',
namedParams: {
addonId: 'dustman',
},
queryParams: {},
},
preview: {
label: 'users',
message: '750',
color: 'blue',
},
keywords: ['amo', 'firefox'],
},
],
},
{
examples: [
{
title: 'Mozilla Add-on',
example: {
pattern: '/amo/v/:addonId',
namedParams: {
addonId: 'dustman',
},
queryParams: {},
},
preview: {
label: 'mozilla add-on',
message: 'v2.1.0',
color: 'blue',
},
keywords: ['amo', 'firefox'],
},
],
},
]
describe('<BadgeExamples />', function() {
it('renders with no examples', function() {
shallow(
<BadgeExamples
baseUrl="https://example.shields.io"
definitions={[]}
onClick={() => {}}
/>
)
})
it('renders an array of examples', function() {
shallow(
<BadgeExamples
baseUrl="https://example.shields.io"
definitions={exampleServiceDefinitions}
onClick={() => {}}
/>
)
})
})

View File

@@ -4,7 +4,7 @@ import { expect } from 'chai'
import { H3 } from './common'
import { CategoryHeading, CategoryHeadings } from './category-headings'
import './enzyme-conf.spec'
import '../enzyme-conf.spec'
const exampleCategories = [{ id: 'cat', name: 'Example category' }]

View File

@@ -3,7 +3,7 @@ import { shallow, render } from 'enzyme'
import { expect } from 'chai'
import * as common from './common'
import './enzyme-conf.spec'
import '../enzyme-conf.spec'
describe('Common modules', function() {
describe('<GlobalStyle />', function() {

View File

@@ -3,7 +3,7 @@ import { shallow, render } from 'enzyme'
import { expect } from 'chai'
import Donate from './donate'
import './enzyme-conf.spec'
import '../enzyme-conf.spec'
describe('<Donate />', function() {
it('renders', function() {

View File

@@ -3,7 +3,7 @@ import { shallow, render } from 'enzyme'
import { expect } from 'chai'
import Footer from './footer'
import './enzyme-conf.spec'
import '../enzyme-conf.spec'
describe('<Footer />', function() {
it('renders', function() {

View File

@@ -3,7 +3,7 @@ import { shallow } from 'enzyme'
import { expect } from 'chai'
import Header from './header'
import './enzyme-conf.spec'
import '../enzyme-conf.spec'
describe('<Header />', function() {
it('renders', function() {

View File

@@ -2,7 +2,7 @@ import React from 'react'
import { shallow } from 'enzyme'
import Main from './main'
import './enzyme-conf.spec'
import '../enzyme-conf.spec'
describe('<Main />', function() {
it('renders without a category', function() {

View File

@@ -3,7 +3,7 @@ import { shallow } from 'enzyme'
import { expect } from 'chai'
import Meta from './meta'
import './enzyme-conf.spec'
import '../enzyme-conf.spec'
describe('<Meta />', function() {
it('renders', function() {

View File

@@ -23,11 +23,8 @@ const StyledCode = styled.code`
padding: 0.1em 0.3em;
border-radius: 4px;
${({ withBackground }) =>
withBackground !== false &&
css`
background: #eef;
`} font-family: Lekton;
background: #eef;
font-family: Lekton;
font-size: ${({ fontSize }) => fontSize};
white-space: nowrap;

View File

@@ -0,0 +1,21 @@
import React from 'react'
import { render } from 'enzyme'
import { Snippet } from './snippet'
import '../enzyme-conf.spec'
describe('<Snippet />', function() {
it('renders', function() {
render(<Snippet snippet="http://example.com/badge.svg" />)
})
it('renders with truncate and fontSize', function() {
render(
<Snippet
fontSize="14pt"
snippet="http://example.com/badge.svg"
truncate
/>
)
})
})

View File

@@ -3,7 +3,7 @@ import { shallow } from 'enzyme'
import { expect } from 'chai'
import Usage from './usage'
import './enzyme-conf.spec'
import '../enzyme-conf.spec'
describe('<Usage />', function() {
it('renders', function() {

View File

@@ -0,0 +1,11 @@
import React from 'react'
import { shallow } from 'enzyme'
import EndpointPage from './endpoint'
import '../enzyme-conf.spec'
describe('<EndpointPage />', function() {
it('renders', function() {
shallow(<EndpointPage pageContext={{}} />)
})
})

View File

@@ -0,0 +1,11 @@
import React from 'react'
import { shallow } from 'enzyme'
import IndexPage from '.'
import '../enzyme-conf.spec'
describe('<IndexPage />', function() {
it('renders', function() {
shallow(<IndexPage pageContext={{}} />)
})
})