@@ -20,27 +20,16 @@ let JSXDEVRuntime;
20
20
// A lot of these tests are pulled from ReactElement-test because
21
21
// this api is meant to be backwards compatible.
22
22
describe ( 'ReactElement.jsx' , ( ) => {
23
- let originalSymbol ;
24
-
25
23
beforeEach ( ( ) => {
26
24
jest . resetModules ( ) ;
27
25
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
-
33
26
React = require ( 'react' ) ;
34
27
JSXRuntime = require ( 'react/jsx-runtime' ) ;
35
28
JSXDEVRuntime = require ( 'react/jsx-dev-runtime' ) ;
36
29
ReactDOM = require ( 'react-dom' ) ;
37
30
ReactTestUtils = require ( 'react-dom/test-utils' ) ;
38
31
} ) ;
39
32
40
- afterEach ( ( ) => {
41
- global . Symbol = originalSymbol ;
42
- } ) ;
43
-
44
33
it ( 'allows static methods to be called using the type property' , ( ) => {
45
34
class StaticMethodComponentClass extends React . Component {
46
35
render ( ) {
@@ -53,47 +42,6 @@ describe('ReactElement.jsx', () => {
53
42
expect ( element . type . someStaticMethod ( ) ) . toBe ( 'someReturnValue' ) ;
54
43
} ) ;
55
44
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
-
97
45
it ( 'is indistinguishable from a plain object' , ( ) => {
98
46
const element = JSXRuntime . jsx ( 'div' , { className : 'foo' } ) ;
99
47
const object = { } ;
@@ -288,34 +236,22 @@ describe('ReactElement.jsx', () => {
288
236
} ) ;
289
237
290
238
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
-
311
239
class Component extends React . Component {
312
240
render ( ) {
313
- return JSXRuntime . jsx ( 'div' ) ;
241
+ return JSXRuntime . jsx ( 'div' , { } ) ;
314
242
}
315
243
}
316
244
317
245
expect ( React . isValidElement ( JSXRuntime . jsx ( 'div' , { } ) ) ) . toEqual ( true ) ;
318
246
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
+ }
319
255
320
256
expect ( React . isValidElement ( null ) ) . toEqual ( false ) ;
321
257
expect ( React . isValidElement ( true ) ) . toEqual ( false ) ;
0 commit comments