Last active
August 1, 2016 03:17
-
-
Save pechitook/361972dafd1eae25ea8273a674e084ff to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Checkbox from 'components/Form/Checkbox'; | |
import expect from 'expect'; | |
import 'jsdom-global/register'; | |
describe('<Checkbox />', () => { | |
it('adds checked attribute to input', () => { | |
const wrapper = shallow(<Checkbox checked />); | |
const input = wrapper.find('input'); | |
expect(input.props().defaultChecked).toBe(true); | |
}); | |
it('adds disabled attribute to input', () => { | |
const wrapper = shallow(<Checkbox disabled />); | |
const input = wrapper.find('input'); | |
expect(input.props().disabled).toBe(true); | |
}); | |
it('calls the onChange function', () => { | |
const onChange = expect.createSpy(); | |
const wrapper = mount(<Checkbox onChange={onChange} />); | |
const input = wrapper.find('input'); | |
input.simulate('change'); | |
expect(onChange).toHaveBeenCalled(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment