Say I have the following component:
export default class CustomInput extends PureComponent {
render () {
return (
<input type='text' value={this.props.value || ''} onChange={this.props.changeHandler} placeholder={this.props.placeholderValue} />
)
}
}
CustomInput.propTypes = {
value: PropTypes.string,
placeholderValue: PropTypes.string,
changeHandler: PropTypes.func.isRequired
}
Which I attempt to test as follows:
test('input renders correctly', () => {
const handler = jest.fn()
const display = shallow(<CustomInput value='foo' placeholderValue='bar' changeHandler={handler}/>)
})
This fails with:
TypeError: Cannot read property 'contextTypes' of undefined
Any help would be much appreciated!