Created
February 7, 2016 19:24
-
-
Save jakubzitny/7b9d526f77b2865219d3 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
it('can pass advanced context to the child of mounted component', () => { | |
const SimpleComponent = React.createClass({ | |
contextTypes: { | |
ctx1: React.PropTypes.string.isRequired, | |
ctx2: React.PropTypes.string.isRequired, | |
}, | |
render() { | |
return <div>{this.context.ctx1}{this.context.ctx2}</div>; | |
}, | |
}); | |
const ComplexComponent = React.createClass({ | |
contextTypes: { | |
ctx1: React.PropTypes.string.isRequired, | |
}, | |
render() { | |
return <div><SimpleComponent /><p>{this.context.ctx1}</p></div>; | |
}, | |
}); | |
const advancedContext = { ctx1: 'ctx1', ctx2: 'ctx2' }; | |
const wrapper = mount(<ComplexComponent />, { context: advancedContext }); | |
expect(wrapper.find(SimpleComponent)).to.have.length(1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment