@@ -25,22 +25,13 @@ describe('ReactElement.jsx', () => {
2525 beforeEach ( ( ) => {
2626 jest . resetModules ( ) ;
2727
28- // Delete the native Symbol if we have one to ensure we test the
29- // unpolyfilled environment.
30- originalSymbol = global . Symbol ;
31- global . Symbol = undefined ;
32-
3328 React = require ( 'react' ) ;
3429 JSXRuntime = require ( 'react/jsx-runtime' ) ;
3530 JSXDEVRuntime = require ( 'react/jsx-dev-runtime' ) ;
3631 ReactDOM = require ( 'react-dom' ) ;
3732 ReactTestUtils = require ( 'react-dom/test-utils' ) ;
3833 } ) ;
3934
40- afterEach ( ( ) => {
41- global . Symbol = originalSymbol ;
42- } ) ;
43-
4435 it ( 'allows static methods to be called using the type property' , ( ) => {
4536 class StaticMethodComponentClass extends React . Component {
4637 render ( ) {
@@ -53,47 +44,6 @@ describe('ReactElement.jsx', () => {
5344 expect ( element . type . someStaticMethod ( ) ) . toBe ( 'someReturnValue' ) ;
5445 } ) ;
5546
56- it ( 'identifies valid elements' , ( ) => {
57- class Component extends React . Component {
58- render ( ) {
59- return JSXRuntime . jsx ( 'div' , { } ) ;
60- }
61- }
62-
63- expect ( React . isValidElement ( JSXRuntime . jsx ( 'div' , { } ) ) ) . toEqual ( true ) ;
64- expect ( React . isValidElement ( JSXRuntime . jsx ( Component , { } ) ) ) . toEqual ( true ) ;
65- expect (
66- React . isValidElement ( JSXRuntime . jsx ( JSXRuntime . Fragment , { } ) ) ,
67- ) . toEqual ( true ) ;
68- if ( __DEV__ ) {
69- expect ( React . isValidElement ( JSXDEVRuntime . jsxDEV ( 'div' , { } ) ) ) . toEqual (
70- true ,
71- ) ;
72- }
73-
74- expect ( React . isValidElement ( null ) ) . toEqual ( false ) ;
75- expect ( React . isValidElement ( true ) ) . toEqual ( false ) ;
76- expect ( React . isValidElement ( { } ) ) . toEqual ( false ) ;
77- expect ( React . isValidElement ( 'string' ) ) . toEqual ( false ) ;
78- if ( ! __EXPERIMENTAL__ ) {
79- let factory ;
80- expect ( ( ) => {
81- factory = React . createFactory ( 'div' ) ;
82- } ) . toWarnDev (
83- 'Warning: React.createFactory() is deprecated and will be removed in a ' +
84- 'future major release. Consider using JSX or use React.createElement() ' +
85- 'directly instead.' ,
86- { withoutStack : true } ,
87- ) ;
88- expect ( React . isValidElement ( factory ) ) . toEqual ( false ) ;
89- }
90- expect ( React . isValidElement ( Component ) ) . toEqual ( false ) ;
91- expect ( React . isValidElement ( { type : 'div' , props : { } } ) ) . toEqual ( false ) ;
92-
93- const jsonElement = JSON . stringify ( JSXRuntime . jsx ( 'div' , { } ) ) ;
94- expect ( React . isValidElement ( JSON . parse ( jsonElement ) ) ) . toBe ( true ) ;
95- } ) ;
96-
9747 it ( 'is indistinguishable from a plain object' , ( ) => {
9848 const element = JSXRuntime . jsx ( 'div' , { className : 'foo' } ) ;
9949 const object = { } ;
@@ -288,34 +238,22 @@ describe('ReactElement.jsx', () => {
288238 } ) ;
289239
290240 it ( 'identifies elements, but not JSON, if Symbols are supported' , ( ) => {
291- // Rudimentary polyfill
292- // Once all jest engines support Symbols natively we can swap this to test
293- // WITH native Symbols by default.
294- const REACT_ELEMENT_TYPE = function ( ) { } ; // fake Symbol
295- const OTHER_SYMBOL = function ( ) { } ; // another fake Symbol
296- global . Symbol = function ( name ) {
297- return OTHER_SYMBOL ;
298- } ;
299- global . Symbol . for = function ( key ) {
300- if ( key === 'react.element' ) {
301- return REACT_ELEMENT_TYPE ;
302- }
303- return OTHER_SYMBOL ;
304- } ;
305-
306- jest . resetModules ( ) ;
307-
308- React = require ( 'react' ) ;
309- JSXRuntime = require ( 'react/jsx-runtime' ) ;
310-
311241 class Component extends React . Component {
312242 render ( ) {
313- return JSXRuntime . jsx ( 'div' ) ;
243+ return JSXRuntime . jsx ( 'div' , { } ) ;
314244 }
315245 }
316246
317247 expect ( React . isValidElement ( JSXRuntime . jsx ( 'div' , { } ) ) ) . toEqual ( true ) ;
318248 expect ( React . isValidElement ( JSXRuntime . jsx ( Component , { } ) ) ) . toEqual ( true ) ;
249+ expect (
250+ React . isValidElement ( JSXRuntime . jsx ( JSXRuntime . Fragment , { } ) ) ,
251+ ) . toEqual ( true ) ;
252+ if ( __DEV__ ) {
253+ expect ( React . isValidElement ( JSXDEVRuntime . jsxDEV ( 'div' , { } ) ) ) . toEqual (
254+ true ,
255+ ) ;
256+ }
319257
320258 expect ( React . isValidElement ( null ) ) . toEqual ( false ) ;
321259 expect ( React . isValidElement ( true ) ) . toEqual ( false ) ;
0 commit comments