This repository was archived by the owner on Sep 1, 2024. It is now read-only.

Description
If I have a stateless functional component such as this:
const SlideView = ({text}) => {
...
return (
<div className="example-slide-view">
{text}
</div>
);
};
SlideView.propTypes = {
text: PropTypes.string.isRequired
};
...
If I test it like this:
context('SlideView...', () => {
context('when called without a "text" prop', () => {
shallow(<SlideView text={undefined} />);
it('should throw a missing prop error', () => {
testUtils.expectMissingPropError('text', 'SlideView');
});
});
});
The test passes.
However, if instead I test the SlideView like this:
context('SlideView...', () => {
context('when called without a "text" prop', () => {
SlideView({text: undefined});
it('should throw a missing prop error', () => {
testUtils.expectMissingPropError('text', 'SlideView');
});
});
});
No prop-types error is logged to the console, so the test fails.
I didn't expect this behaviour. I think it would be useful if the props were validated in this case.