@@ -20,27 +20,16 @@ let JSXDEVRuntime;
2020// A lot of these tests are pulled from ReactElement-test because
2121// this api is meant to be backwards compatible.
2222describe ( 'ReactElement.jsx' , ( ) => {
23- let originalSymbol ;
24-
2523 beforeEach ( ( ) => {
2624 jest . resetModules ( ) ;
2725
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-
3326 React = require ( 'react' ) ;
3427 JSXRuntime = require ( 'react/jsx-runtime' ) ;
3528 JSXDEVRuntime = require ( 'react/jsx-dev-runtime' ) ;
3629 ReactDOM = require ( 'react-dom' ) ;
3730 ReactTestUtils = require ( 'react-dom/test-utils' ) ;
3831 } ) ;
3932
40- afterEach ( ( ) => {
41- global . Symbol = originalSymbol ;
42- } ) ;
43-
4433 it ( 'allows static methods to be called using the type property' , ( ) => {
4534 class StaticMethodComponentClass extends React . Component {
4635 render ( ) {
@@ -53,47 +42,6 @@ describe('ReactElement.jsx', () => {
5342 expect ( element . type . someStaticMethod ( ) ) . toBe ( 'someReturnValue' ) ;
5443 } ) ;
5544
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-
9745 it ( 'is indistinguishable from a plain object' , ( ) => {
9846 const element = JSXRuntime . jsx ( 'div' , { className : 'foo' } ) ;
9947 const object = { } ;
@@ -288,34 +236,22 @@ describe('ReactElement.jsx', () => {
288236 } ) ;
289237
290238 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-
311239 class Component extends React . Component {
312240 render ( ) {
313- return JSXRuntime . jsx ( 'div' ) ;
241+ return JSXRuntime . jsx ( 'div' , { } ) ;
314242 }
315243 }
316244
317245 expect ( React . isValidElement ( JSXRuntime . jsx ( 'div' , { } ) ) ) . toEqual ( true ) ;
318246 expect ( React . isValidElement ( JSXRuntime . jsx ( Component , { } ) ) ) . toEqual ( true ) ;
247+ expect (
248+ React . isValidElement ( JSXRuntime . jsx ( JSXRuntime . Fragment , { } ) ) ,
249+ ) . toEqual ( true ) ;
250+ if ( __DEV__ ) {
251+ expect ( React . isValidElement ( JSXDEVRuntime . jsxDEV ( 'div' , { } ) ) ) . toEqual (
252+ true ,
253+ ) ;
254+ }
319255
320256 expect ( React . isValidElement ( null ) ) . toEqual ( false ) ;
321257 expect ( React . isValidElement ( true ) ) . toEqual ( false ) ;
0 commit comments