Improve coverage in frontend and remove some dead code (#3031)
This commit is contained in:
@@ -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)
|
||||
|
||||
126
frontend/components/badge-examples.spec.js
Normal file
126
frontend/components/badge-examples.spec.js
Normal 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={() => {}}
|
||||
/>
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -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' }]
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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;
|
||||
|
||||
21
frontend/components/snippet.spec.js
Normal file
21
frontend/components/snippet.spec.js
Normal 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
|
||||
/>
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -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() {
|
||||
|
||||
11
frontend/pages/endpoint.spec.js
Normal file
11
frontend/pages/endpoint.spec.js
Normal 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={{}} />)
|
||||
})
|
||||
})
|
||||
11
frontend/pages/index.spec.js
Normal file
11
frontend/pages/index.spec.js
Normal 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={{}} />)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user