mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
ReactIs.isValidElementType Unit Test extended with PureComponent case (#20033)
Co-authored-by: Adam Plocieniak <adam.plocieniak@allegro.pl>
This commit is contained in:
@@ -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', () => {
|
||||
@@ -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) =>
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user