Add some basic frontend tests (#2490)

The frontend has a few tests in `lib/` but not all of that is covered. The components are not covered at all. It's difficult to make changes to the frontend because you have to manually test that things haven't broken.

This PR uses [Enzyme](https://airbnb.io/enzyme/) to add some [shallow-rendering tests](https://github.com/airbnb/enzyme/blob/master/docs/api/shallow.md), which are essentially unit tests of the components.

This should pave the way for functional tests of the more complex components.
This commit is contained in:
Paul Melnikow
2018-12-10 17:20:01 -05:00
committed by GitHub
parent 0a98bd3121
commit a677c5bbef
11 changed files with 620 additions and 66 deletions

View File

@@ -0,0 +1,17 @@
import React from 'react'
import { shallow } from 'enzyme'
import { expect } from 'chai'
import Header from './header'
import './enzyme-conf.spec'
describe('<Header />', function() {
it('renders', function() {
shallow(<Header />)
})
it('contains the word Hackable', function() {
const wrapper = shallow(<Header />)
expect(wrapper).to.contain.text('Hackable')
})
})