Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should filter out context not in contextTypes', function() {
class MyComponent extends Component {
static contextTypes = {
foo: PropTypes.string,
};
render() {
return <div>;
}
}
class ComponentInFooBarContext extends Component {
static childContextTypes = {
foo: PropTypes.string,
bar: PropTypes.number,
};
getChildContext() {
return {
foo: 'abc',
bar: 123,
};
}
render() {
return ;
}
}
let instance = render();
expect(instance._internal._renderedComponent._instance.context).toEqual({foo: 'abc'});</div>