Skip to content

Commit

Permalink
ReactIs.isValidElementType Unit Test extended with PureComponent case (
Browse files Browse the repository at this point in the history
…#20033)

Co-authored-by: Adam Plocieniak <adam.plocieniak@allegro.pl>
  • Loading branch information
adasq and Adam Plocieniak authored Oct 15, 2020
1 parent 02da938 commit c57fe4a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/react-is/src/__tests__/ReactIs-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ describe('ReactIs', () => {
expect(ReactIs.typeOf({})).toBe(undefined);
expect(ReactIs.typeOf(null)).toBe(undefined);
expect(ReactIs.typeOf(undefined)).toBe(undefined);
expect(ReactIs.typeOf(NaN)).toBe(undefined);
expect(ReactIs.typeOf(Symbol('def'))).toBe(undefined);
});

it('identifies valid element types', () => {
Expand All @@ -37,6 +39,11 @@ describe('ReactIs', () => {
return React.createElement('div');
}
}
class PureComponent extends React.PureComponent {
render() {
return React.createElement('div');
}
}

const FunctionComponent = () => React.createElement('div');
const ForwardRefComponent = React.forwardRef((props, ref) =>
Expand All @@ -48,6 +55,7 @@ describe('ReactIs', () => {

expect(ReactIs.isValidElementType('div')).toEqual(true);
expect(ReactIs.isValidElementType(Component)).toEqual(true);
expect(ReactIs.isValidElementType(PureComponent)).toEqual(true);
expect(ReactIs.isValidElementType(FunctionComponent)).toEqual(true);
expect(ReactIs.isValidElementType(ForwardRefComponent)).toEqual(true);
expect(ReactIs.isValidElementType(LazyComponent)).toEqual(true);
Expand Down

0 comments on commit c57fe4a

Please sign in to comment.