Created
June 7, 2016 23:03
-
-
Save goldhand/6cdbc2bcce27e6d391586cb71fd05207 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
jest.unmock('../components/Counter'); | |
import React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import TestUtils from 'react-addons-test-utils'; | |
import Counter from '../components/Counter'; | |
describe('Counter Component', () => { | |
it('incrment or decrement count after click', () => { | |
let count = 0; | |
const counter = TestUtils.renderIntoDocument( | |
<Counter incrementCounter={() => count++} decrementCounter={() => count--} value={count}/> | |
); | |
const counterNode = ReactDOM.findDOMNode(counter); | |
expect(counterNode.textContent).toEqual('Counter: 0+-'); | |
TestUtils.Simulate.click( | |
TestUtils.scryRenderedDOMComponentsWithTag(counter, 'button')[0] | |
); | |
expect(count).toEqual(1); | |
TestUtils.Simulate.click( | |
TestUtils.scryRenderedDOMComponentsWithTag(counter, 'button')[1] | |
); | |
expect(count).toEqual(0); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment