From 13069bf5da115de6fd4b2482a7bf66d22c7bed05 Mon Sep 17 00:00:00 2001 From: Adam Plocieniak Date: Thu, 15 Oct 2020 12:37:05 +0200 Subject: [PATCH 1/2] ReactIs.isValidElementType Unit Test extended with PureComponent case --- packages/react-is/src/__tests__/ReactIs-test.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/react-is/src/__tests__/ReactIs-test.js b/packages/react-is/src/__tests__/ReactIs-test.js index a56c9f756a1d3..37a75abb8eb62 100644 --- a/packages/react-is/src/__tests__/ReactIs-test.js +++ b/packages/react-is/src/__tests__/ReactIs-test.js @@ -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); @@ -60,8 +68,8 @@ describe('ReactIs', () => { factory = React.createFactory('div'); }).toWarnDev( 'Warning: React.createFactory() is deprecated and will be removed in a ' + - 'future major release. Consider using JSX or use React.createElement() ' + - 'directly instead.', + 'future major release. Consider using JSX or use React.createElement() ' + + 'directly instead.', {withoutStack: true}, ); expect(ReactIs.isValidElementType(factory)).toEqual(true); From 07cf269a4f31250e9d0fff5f5e1c84d436c92058 Mon Sep 17 00:00:00 2001 From: Adam Plocieniak Date: Thu, 15 Oct 2020 13:04:13 +0200 Subject: [PATCH 2/2] prettier changes applied --- packages/react-is/src/__tests__/ReactIs-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-is/src/__tests__/ReactIs-test.js b/packages/react-is/src/__tests__/ReactIs-test.js index 37a75abb8eb62..cddd479c4344e 100644 --- a/packages/react-is/src/__tests__/ReactIs-test.js +++ b/packages/react-is/src/__tests__/ReactIs-test.js @@ -68,8 +68,8 @@ describe('ReactIs', () => { factory = React.createFactory('div'); }).toWarnDev( 'Warning: React.createFactory() is deprecated and will be removed in a ' + - 'future major release. Consider using JSX or use React.createElement() ' + - 'directly instead.', + 'future major release. Consider using JSX or use React.createElement() ' + + 'directly instead.', {withoutStack: true}, ); expect(ReactIs.isValidElementType(factory)).toEqual(true);