10
10
'use strict' ;
11
11
12
12
let React ;
13
- let ReactFeatureFlags ;
14
13
let ReactNoop ;
15
14
let Scheduler ;
16
15
17
16
describe ( 'ReactSuspense' , ( ) => {
18
17
beforeEach ( ( ) => {
19
18
jest . resetModules ( ) ;
20
- ReactFeatureFlags = require ( 'shared/ReactFeatureFlags' ) ;
21
- ReactFeatureFlags . enableSuspenseCallback = true ;
22
19
23
20
React = require ( 'react' ) ;
24
21
ReactNoop = require ( 'react-noop-renderer' ) ;
@@ -47,30 +44,34 @@ describe('ReactSuspense', () => {
47
44
return { promise, resolve, PromiseComp} ;
48
45
}
49
46
50
- it ( 'check type' , ( ) => {
51
- const { PromiseComp} = createThenable ( ) ;
47
+ if ( __DEV__ ) {
48
+ // @gate www
49
+ it ( 'check type' , ( ) => {
50
+ const { PromiseComp} = createThenable ( ) ;
52
51
53
- const elementBadType = (
54
- < React . Suspense suspenseCallback = { 1 } fallback = { 'Waiting' } >
55
- < PromiseComp />
56
- </ React . Suspense >
57
- ) ;
52
+ const elementBadType = (
53
+ < React . Suspense suspenseCallback = { 1 } fallback = { 'Waiting' } >
54
+ < PromiseComp />
55
+ </ React . Suspense >
56
+ ) ;
58
57
59
- ReactNoop . render ( elementBadType ) ;
60
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev ( [
61
- 'Warning: Unexpected type for suspenseCallback.' ,
62
- ] ) ;
58
+ ReactNoop . render ( elementBadType ) ;
59
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev ( [
60
+ 'Warning: Unexpected type for suspenseCallback.' ,
61
+ ] ) ;
63
62
64
- const elementMissingCallback = (
65
- < React . Suspense fallback = { 'Waiting' } >
66
- < PromiseComp />
67
- </ React . Suspense >
68
- ) ;
63
+ const elementMissingCallback = (
64
+ < React . Suspense fallback = { 'Waiting' } >
65
+ < PromiseComp />
66
+ </ React . Suspense >
67
+ ) ;
69
68
70
- ReactNoop . render ( elementMissingCallback ) ;
71
- expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev ( [ ] ) ;
72
- } ) ;
69
+ ReactNoop . render ( elementMissingCallback ) ;
70
+ expect ( ( ) => Scheduler . unstable_flushAll ( ) ) . toErrorDev ( [ ] ) ;
71
+ } ) ;
72
+ }
73
73
74
+ // @gate www
74
75
it ( '1 then 0 suspense callback' , async ( ) => {
75
76
const { promise, resolve, PromiseComp} = createThenable ( ) ;
76
77
@@ -97,6 +98,7 @@ describe('ReactSuspense', () => {
97
98
expect ( ops ) . toEqual ( [ ] ) ;
98
99
} ) ;
99
100
101
+ // @gate www
100
102
it ( '2 then 1 then 0 suspense callback' , async ( ) => {
101
103
const {
102
104
promise : promise1 ,
@@ -143,6 +145,7 @@ describe('ReactSuspense', () => {
143
145
expect ( ops ) . toEqual ( [ ] ) ;
144
146
} ) ;
145
147
148
+ // @gate www
146
149
it ( 'nested suspense promises are reported only for their tier' , ( ) => {
147
150
const { promise, PromiseComp} = createThenable ( ) ;
148
151
@@ -174,6 +177,7 @@ describe('ReactSuspense', () => {
174
177
expect ( ops2 ) . toEqual ( [ new Set ( [ promise ] ) ] ) ;
175
178
} ) ;
176
179
180
+ // @gate www
177
181
it ( 'competing suspense promises' , async ( ) => {
178
182
const {
179
183
promise : promise1 ,
@@ -242,6 +246,7 @@ describe('ReactSuspense', () => {
242
246
} ) ;
243
247
244
248
if ( __DEV__ ) {
249
+ // @gate www
245
250
it ( 'regression test for #16215 that relies on implementation details' , async ( ) => {
246
251
// Regression test for https://github.com/facebook/react/pull/16215.
247
252
// The bug only happens if there's an error earlier in the commit phase.
@@ -272,9 +277,6 @@ describe('ReactSuspense', () => {
272
277
} ,
273
278
} ) ) ;
274
279
275
- ReactFeatureFlags = require ( 'shared/ReactFeatureFlags' ) ;
276
- ReactFeatureFlags . enableSuspenseCallback = true ;
277
-
278
280
React = require ( 'react' ) ;
279
281
ReactNoop = require ( 'react-noop-renderer' ) ;
280
282
Scheduler = require ( 'scheduler' ) ;
0 commit comments