Created
April 21, 2016 22:15
-
-
Save darthwade/721aa0f52663be352ee623d9245c3bd3 to your computer and use it in GitHub Desktop.
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
'use strict'; | |
jest.unmock('../CheckboxWithLabel'); | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import TestUtils from 'react-addons-test-utils'; | |
import CheckboxWithLabel from '../CheckboxWithLabel'; | |
describe('CheckboxWithLabel', () => { | |
it('changes the text after click', () => { | |
// Render a checkbox with label in the document | |
const checkbox = TestUtils.renderIntoDocument( | |
<CheckboxWithLabel labelOn="On" labelOff="Off" /> | |
); | |
const checkboxNode = ReactDOM.findDOMNode(checkbox); | |
// Verify that it's Off by default | |
expect(checkboxNode.textContent).toEqual('Off'); | |
// Simulate a click and verify that it is now On | |
TestUtils.Simulate.change( | |
TestUtils.findRenderedDOMComponentWithTag(checkbox, 'input') | |
); | |
expect(checkboxNode.textContent).toEqual('On'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment