Created
May 27, 2016 16:45
-
-
Save kevinsalter/f1bdd6adbd8dc814c67e3426147359cd to your computer and use it in GitHub Desktop.
<MainView /> 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} from 'enzyme'; | |
import {assert} from 'chai'; | |
import {spy} from 'sinon'; | |
import MainView from '../src/main-view.js'; | |
import {Users} from '../fixtures/users.js'; | |
describe('<MainView />', () => { | |
const MAIN_VIEW_PROPS = { | |
ghUsers: Users, | |
refreshUserList: spy() | |
}; | |
it('should contain a list of users', () => { | |
const wrapper = shallow(<MainView {...MAIN_VIEW_PROPS} />); | |
const listWrapper = wrapper.find('ul'); | |
assert.equal(listWrapper.length, 1); | |
assert.ok(listWrapper.children()); | |
}); | |
it('should call the refreshUserList() method when button is clicked', () => { | |
const wrapper = shallow(<MainView {...MAIN_VIEW_PROPS} />); | |
const refreshUserListButton = wrapper.find('button'); | |
refreshUserListButton.simulate('click'); | |
assert.ok(MAIN_VIEW_PROPS.refreshUserList.calledOnce); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment