Add some more perfunctory coverage of the frontend (#2962)

This commit is contained in:
Paul Melnikow
2019-02-10 14:34:17 -06:00
committed by chris48s
parent 1379ea3980
commit 725ffca2d1
4 changed files with 112 additions and 0 deletions

View File

@@ -0,0 +1,67 @@
import React from 'react'
import { shallow, render } from 'enzyme'
import { expect } from 'chai'
import * as common from './common'
import './enzyme-conf.spec'
describe('Common modules', function() {
describe('<GlobalStyle />', function() {
it('renders', function() {
shallow(<common.GlobalStyle />)
})
})
describe('<BaseFont />', function() {
it('renders', function() {
shallow(<common.BaseFont />)
})
})
describe('<H2 />', function() {
it('renders', function() {
shallow(<common.H2 />)
})
})
describe('<H3 />', function() {
it('renders', function() {
shallow(<common.H3 />)
})
})
describe('<Badge />', function() {
it('renders', function() {
shallow(<common.Badge src="/badge/foo-bar-blue.svg" />)
})
it('contains a link to the image', function() {
const wrapper = render(<common.Badge src="/badge/foo-bar-blue.svg" />)
expect(wrapper.html()).to.contain('<img src="/badge/foo-bar-blue.svg"')
})
})
describe('<StyledInput />', function() {
it('renders', function() {
shallow(<common.StyledInput />)
})
})
describe('<InlineInput />', function() {
it('renders', function() {
shallow(<common.InlineInput />)
})
})
describe('<BlockInput />', function() {
it('renders', function() {
shallow(<common.BlockInput />)
})
})
describe('<VerticalSpace />', function() {
it('renders', function() {
shallow(<common.VerticalSpace />)
})
})
})

View File

@@ -0,0 +1,17 @@
import React from 'react'
import { shallow, render } from 'enzyme'
import { expect } from 'chai'
import Donate from './donate'
import './enzyme-conf.spec'
describe('<Donate />', function() {
it('renders', function() {
shallow(<Donate />)
})
it('contains a link to open collective', function() {
const wrapper = render(<Donate />)
expect(wrapper.html()).to.contain('https://opencollective.com/shields')
})
})

View File

@@ -0,0 +1,21 @@
import React from 'react'
import { shallow } from 'enzyme'
import Main from './main'
import './enzyme-conf.spec'
describe('<Main />', function() {
it('renders without a category', function() {
shallow(<Main pageContext={{}} />)
})
it('renders with a category', function() {
shallow(
<Main
pageContext={{
category: { id: 'build', name: 'Build' },
}}
/>
)
})
})

View File

@@ -14,4 +14,11 @@ describe('<Usage />', function() {
const wrapper = shallow(<Usage baseUrl="https://example.shields.io" />)
expect(wrapper).to.contain.text('use them responsibly')
})
// This test requires Link to be mocked.
// const wrapper = render(<Usage baseUrl="https://example.shields.io" />)
// expect(wrapper.html()).to.contain(
// 'needed for spaces or special characters!'
// )
// })
})