Created
May 27, 2016 16:43
-
-
Save kevinsalter/bbc316b7e8dbb6d60e6dec8fc33dd839 to your computer and use it in GitHub Desktop.
<Container /> unit tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import {shallow, mount} from 'enzyme'; | |
import {assert} from 'chai'; | |
import {spy} from 'sinon'; | |
import Container from '../src/container.js'; | |
describe('<Container />', () => { | |
it('should show the <Loading /> component be default', () => { | |
const wrapper = shallow(<Container />); | |
const container = wrapper.first('div'); | |
const loadingComponent = wrapper.find('Loading'); | |
assert.equal(container.length, 1); | |
assert.equal(loadingComponent.length, 1); | |
}); | |
it('should show the <MainView /> component when it has loaded', () => { | |
const wrapper = shallow(<Container />); | |
wrapper.setState({loading: false}); | |
const mainView = wrapper.find('MainView'); | |
assert.equal(mainView.length, 1); | |
}); | |
it('calls componentDidMount() lifecycle method', () => { | |
const componentDidMountSpy = spy(Container.prototype, 'componentDidMount'); | |
const wrapper = mount(<Container />); | |
assert.ok(Container.prototype.componentDidMount.calledOnce); | |
componentDidMountSpy.restore(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment