File tree Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ describe('renderPrepass', () => {
3737 } )
3838 } )
3939
40- it ( 'preserves the correct context values across yields' , ( ) => {
40+ it ( 'preserves the correct legacy context values across yields' , ( ) => {
4141 let called = false
4242 const Inner = ( _ , context ) => {
4343 expect ( context . test ) . toBe ( 123 )
@@ -66,7 +66,38 @@ describe('renderPrepass', () => {
6666
6767 const render$ = renderPrepass ( < Outer /> )
6868 expect ( called ) . toBe ( false )
69+ return render$ . then ( ( ) => {
70+ expect ( called ) . toBe ( true )
71+ } )
72+ } )
73+
74+ it ( 'preserves the correct context values across yields' , ( ) => {
75+ const Context = createContext ( null )
6976
77+ let called = false
78+ const Inner = ( ) => {
79+ const value = useContext ( Context )
80+ expect ( value ) . toBe ( 123 )
81+ called = true
82+ return null
83+ }
84+
85+ const Wait = ( ) => {
86+ const start = Date . now ( )
87+ while ( Date . now ( ) - start < 21 ) { }
88+ return < Inner />
89+ }
90+
91+ const Outer = ( ) => {
92+ return (
93+ < Context . Provider value = { 123 } >
94+ < Wait />
95+ </ Context . Provider >
96+ )
97+ }
98+
99+ const render$ = renderPrepass ( < Outer /> )
100+ expect ( called ) . toBe ( false )
70101 return render$ . then ( ( ) => {
71102 expect ( called ) . toBe ( true )
72103 } )
You can’t perform that action at this time.
0 commit comments