Add shallow context pass test

This commit is contained in:
Sławomir Laskowski
2015-05-21 00:08:31 +02:00
parent 1d7da35153
commit 2c83627ca8
+18
View File
@@ -159,6 +159,24 @@ describe('ReactTestUtils', function() {
expect(result).toEqual(<div />);
});
it('can pass context when shallowly rendering', function() {
var SimpleComponent = React.createClass({
contextTypes: {
name: React.PropTypes.string,
},
render: function() {
return <div>{this.context.name}</div>;
},
});
var shallowRenderer = ReactTestUtils.createRenderer();
shallowRenderer.render(<SimpleComponent />, {
name: "foo",
});
var result = shallowRenderer.getRenderOutput();
expect(result).toEqual(<div>foo</div>);
});
it('Test scryRenderedDOMComponentsWithClass with TextComponent', function() {
var renderedComponent = ReactTestUtils.renderIntoDocument(<div>Hello <span>Jim</span></div>);
var scryResults = ReactTestUtils.scryRenderedDOMComponentsWithClass(