Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactIs.isValidElementType Unit Test extended with PureComponent case #20033

Merged
merged 2 commits into from
Oct 15, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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