@@ -33,8 +33,7 @@ function initModules() {
33
33
} ;
34
34
}
35
35
36
- const { resetModules, itRenders, clientRenderOnBadMarkup} =
37
- ReactDOMServerIntegrationUtils ( initModules ) ;
36
+ const { resetModules, itRenders} = ReactDOMServerIntegrationUtils ( initModules ) ;
38
37
39
38
describe ( 'ReactDOMServerIntegration' , ( ) => {
40
39
beforeEach ( ( ) => {
@@ -298,115 +297,29 @@ describe('ReactDOMServerIntegration', () => {
298
297
expect ( e . querySelector ( '#language3' ) . textContent ) . toBe ( 'french' ) ;
299
298
} ) ;
300
299
301
- itRenders (
302
- 'should warn with an error message when using Context as consumer in DEV' ,
303
- async render => {
304
- const Theme = React . createContext ( 'dark' ) ;
305
- const Language = React . createContext ( 'french' ) ;
306
-
307
- const App = ( ) => (
308
- < div >
309
- < Theme . Provider value = "light" >
310
- < Language . Provider value = "english" >
311
- < Theme . Provider value = "dark" >
312
- < Theme > { theme => < div id = "theme1" > { theme } </ div > } </ Theme >
313
- </ Theme . Provider >
314
- </ Language . Provider >
315
- </ Theme . Provider >
316
- </ div >
317
- ) ;
318
- // We expect 1 error.
319
- await render ( < App /> , 1 ) ;
320
- } ,
321
- ) ;
322
-
323
- // False positive regression test.
324
- itRenders (
325
- 'should not warn when using Consumer from React < 16.6 with newer renderer' ,
326
- async render => {
327
- const Theme = React . createContext ( 'dark' ) ;
328
- const Language = React . createContext ( 'french' ) ;
329
- // React 16.5 and earlier didn't have a separate object.
330
- Theme . Consumer = Theme ;
331
-
332
- const App = ( ) => (
333
- < div >
334
- < Theme . Provider value = "light" >
335
- < Language . Provider value = "english" >
336
- < Theme . Provider value = "dark" >
337
- < Theme > { theme => < div id = "theme1" > { theme } </ div > } </ Theme >
338
- </ Theme . Provider >
339
- </ Language . Provider >
340
- </ Theme . Provider >
341
- </ div >
342
- ) ;
343
- // We expect 0 errors.
344
- await render ( < App /> , 0 ) ;
345
- } ,
346
- ) ;
347
-
348
- itRenders (
349
- 'should warn with an error message when using nested context consumers in DEV' ,
350
- async render => {
351
- const App = ( ) => {
352
- const Theme = React . createContext ( 'dark' ) ;
353
- const Language = React . createContext ( 'french' ) ;
300
+ itRenders ( 'should treat Context as Context.Provider' , async render => {
301
+ const Theme = React . createContext ( 'dark' ) ;
302
+ const Language = React . createContext ( 'french' ) ;
354
303
355
- return (
356
- < div >
357
- < Theme . Provider value = "light" >
358
- < Language . Provider value = "english" >
359
- < Theme . Provider value = "dark" >
360
- < Theme . Consumer . Consumer >
361
- { theme => < div id = "theme1" > { theme } </ div > }
362
- </ Theme . Consumer . Consumer >
363
- </ Theme . Provider >
364
- </ Language . Provider >
365
- </ Theme . Provider >
366
- </ div >
367
- ) ;
368
- } ;
369
- await render (
370
- < App /> ,
371
- render === clientRenderOnBadMarkup
372
- ? // On hydration mismatch we retry and therefore log the warning again.
373
- 2
374
- : 1 ,
375
- ) ;
376
- } ,
377
- ) ;
304
+ expect ( Theme . Provider ) . toBe ( Theme ) ;
378
305
379
- itRenders (
380
- 'should warn with an error message when using Context.Consumer.Provider DEV' ,
381
- async render => {
382
- const App = ( ) => {
383
- const Theme = React . createContext ( 'dark' ) ;
384
- const Language = React . createContext ( 'french' ) ;
306
+ const App = ( ) => (
307
+ < div >
308
+ < Theme value = "light" >
309
+ < Language value = "english" >
310
+ < Theme value = "dark" >
311
+ < Theme . Consumer >
312
+ { theme => < div id = "theme1" > { theme } </ div > }
313
+ </ Theme . Consumer >
314
+ </ Theme >
315
+ </ Language >
316
+ </ Theme >
317
+ </ div >
318
+ ) ;
385
319
386
- return (
387
- < div >
388
- < Theme . Provider value = "light" >
389
- < Language . Provider value = "english" >
390
- < Theme . Consumer . Provider value = "dark" >
391
- < Theme . Consumer >
392
- { theme => < div id = "theme1" > { theme } </ div > }
393
- </ Theme . Consumer >
394
- </ Theme . Consumer . Provider >
395
- </ Language . Provider >
396
- </ Theme . Provider >
397
- </ div >
398
- ) ;
399
- } ;
400
-
401
- await render (
402
- < App /> ,
403
- render === clientRenderOnBadMarkup
404
- ? // On hydration mismatch we retry and therefore log the warning again.
405
- 2
406
- : 1 ,
407
- ) ;
408
- } ,
409
- ) ;
320
+ const e = await render ( < App /> , 0 ) ;
321
+ expect ( e . textContent ) . toBe ( 'dark' ) ;
322
+ } ) ;
410
323
411
324
it ( 'does not pollute parallel node streams' , ( ) => {
412
325
const LoggedInUser = React . createContext ( ) ;
0 commit comments