-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbutton.js
28 lines (24 loc) · 1.08 KB
/
button.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/** @jsx React.DOM */
jest.dontMock('../js/button.jsx');
var React = require('react/addons');
var GronkButton = require('../js/button.jsx');
var TestUtils = React.addons.TestUtils;
describe('button test', function() {
it('changes the text after click', function() {
var button = <GronkButton name="hi"/>;
var DOM = TestUtils.renderIntoDocument(button);
expect(DOM.refs.gronkButton.getDOMNode().textContent).toEqual('hi Count : 0');
React.addons.TestUtils.Simulate.click(DOM.refs.button.getDOMNode());
expect(DOM.refs.gronkButton.getDOMNode().textContent).toEqual('hi Count : 1');
});
it('changes the text after multiple clicks', function() {
var button = <GronkButton name="hi"/>;
TestUtils.renderIntoDocument(button);
var DOM = TestUtils.renderIntoDocument(button);
expect(DOM.refs.gronkButton.getDOMNode().textContent).toEqual('hi Count : 0');
for(var i = 1; i < 10; i++){
React.addons.TestUtils.Simulate.click(DOM.refs.button.getDOMNode());
expect(DOM.refs.gronkButton.getDOMNode().textContent).toEqual('hi Count : '+i);
}
});
});