React Jest测试

一、

 1 var jest = require('jest');
 2 
 3 jest.dontMock('../CheckboxWithLabel.js');
 4 describe('CheckboxWithLabel', function() {
 5     it('changes the text after click', function() {
 6         var React = require('react/addons');
 7         var CheckboxWithLabel = require('../CheckboxWithLabel.js');
 8         var TestUtils = React.addons.TestUtils;
 9         var checkbox = TestUtils.renderIntoDocument( < CheckboxWithLabel labelOn = "On"
10             labelOff = "Off" / > );
11         var label = TestUtils.findRenderedDOMComponentWithTag(checkbox, 'label');
12         expect(label.getDOMNode().textContent).toEqual('Off');
13         var input = TestUtils.findRenderedDOMComponentWithTag(checkbox, 'input');
14         TestUtils.Simulate.change(input);
15         expect(label.getDOMNode().textContent).toEqual('On');
16     });
17 });

 

posted @ 2015-12-20 20:25  shamgod  阅读(373)  评论(0编辑  收藏  举报
haha