ReactIs.isValidElementType Unit Test extended with PureComponent case (#20033)
Co-authored-by: Adam Plocieniak <adam.plocieniak@allegro.pl>
adasq committed
Oct 15, 2020 at 14:48 UTC
c57fe4a2c1402acdbf31ac48cfc6a6bf336c4067
1 file changed
+8
packages/react-is/src/__tests__/ReactIs-test.js
+8
@@ -29,6 +29,8 @@ describe('ReactIs', () => {
29
expect(ReactIs.typeOf({})).toBe(undefined);
30
expect(ReactIs.typeOf(null)).toBe(undefined);
31
expect(ReactIs.typeOf(undefined)).toBe(undefined);
32
+ expect(ReactIs.typeOf(NaN)).toBe(undefined);
33
+ expect(ReactIs.typeOf(Symbol('def'))).toBe(undefined);
34
});
35
36
it('identifies valid element types', () => {
@@ -37,6 +39,11 @@ describe('ReactIs', () => {
39
return React.createElement('div');
40
}
41
}
42
+ class PureComponent extends React.PureComponent {
43
+ render() {
44
+ return React.createElement('div');
45
+ }
46
+ }
47
48
const FunctionComponent = () => React.createElement('div');
49
const ForwardRefComponent = React.forwardRef((props, ref) =>
@@ -48,6 +55,7 @@ describe('ReactIs', () => {
55
56
expect(ReactIs.isValidElementType('div')).toEqual(true);
57
expect(ReactIs.isValidElementType(Component)).toEqual(true);
58
+ expect(ReactIs.isValidElementType(PureComponent)).toEqual(true);
59
expect(ReactIs.isValidElementType(FunctionComponent)).toEqual(true);
60
expect(ReactIs.isValidElementType(ForwardRefComponent)).toEqual(true);
61
expect(ReactIs.isValidElementType(LazyComponent)).toEqual(true);