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 be exported', () => {
expect(React.Component).toEqual(Component);
});
});
constructor(props, context) {
super(props, context);
this.state = { tag: context.tag, className: this.context.className };
}
render() {
var Tag = this.state.tag;
return ;
}
}
Foo.contextTypes = {
tag: React.PropTypes.string,
className: React.PropTypes.string
};
class Outer extends React.Component {
getChildContext() {
return { tag: 'span', className: 'foo' };
}
render() {
return ;
}
}
Outer.childContextTypes = {
tag: React.PropTypes.string,
className: React.PropTypes.string
};
test(, 'SPAN', 'foo');
});
it('will call all the normal life cycle methods', function() {
var lifeCycles = [];
class Foo extends React.Component {
constructor() {
super();
this.state = {};
}
componentWillMount() {
lifeCycles.push('will-mount');
}
componentDidMount() {
lifeCycles.push('did-mount');
}
componentWillReceiveProps(nextProps) {
lifeCycles.push('receive-props', nextProps);
}
shouldComponentUpdate(nextProps, nextState) {
lifeCycles.push('should-update', nextProps, nextState);
return true;
it('supports this.context passed via getChildContext', function() {
class Bar extends React.Component {
render() {
return <div>;
}
}
Bar.contextTypes = { bar: React.PropTypes.string };
class Foo extends React.Component {
getChildContext() {
return { bar: 'bar-through-context' };
}
render() {
return ;
}
}
Foo.childContextTypes = { bar: React.PropTypes.string };
test(, 'DIV', 'bar-through-context');
});</div>
beforeEach(function() {
container = document.createElement('div');
attachedListener = null;
renderedName = null;
Inner = class extends React.Component {
getName() {
return this.props.name;
}
render() {
attachedListener = this.props.onClick;
renderedName = this.props.name;
return <div>;
}
};
});
</div>