@@ -102,7 +102,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
102102 function Foo ( ) {
103103 ReactNoop . yield ( 'Foo' ) ;
104104 return (
105- < Suspense >
105+ < Suspense fallback = { < Text text = "Loading..." /> } >
106106 < Bar >
107107 < AsyncText text = "A" ms = { 100 } />
108108 < Text text = "B" />
@@ -119,6 +119,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
119119 'Suspend! [A]' ,
120120 // But we keep rendering the siblings
121121 'B' ,
122+ 'Loading...' ,
122123 ] ) ;
123124 expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
124125
@@ -191,15 +192,21 @@ describe('ReactSuspenseWithNoopRenderer', () => {
191192
192193 it ( 'continues rendering siblings after suspending' , async ( ) => {
193194 ReactNoop . render (
194- < Suspense >
195+ < Suspense fallback = { < Text text = "Loading..." /> } >
195196 < Text text = "A" />
196197 < AsyncText text = "B" />
197198 < Text text = "C" />
198199 < Text text = "D" />
199200 </ Suspense > ,
200201 ) ;
201202 // B suspends. Continue rendering the remaining siblings.
202- expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'A' , 'Suspend! [B]' , 'C' , 'D' ] ) ;
203+ expect ( ReactNoop . flush ( ) ) . toEqual ( [
204+ 'A' ,
205+ 'Suspend! [B]' ,
206+ 'C' ,
207+ 'D' ,
208+ 'Loading...' ,
209+ ] ) ;
203210 // Did not commit yet.
204211 expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
205212
@@ -241,7 +248,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
241248 const errorBoundary = React . createRef ( ) ;
242249 function App ( ) {
243250 return (
244- < Suspense >
251+ < Suspense fallback = { < Text text = "Loading..." /> } >
245252 < ErrorBoundary ref = { errorBoundary } >
246253 < AsyncText text = "Result" ms = { 1000 } />
247254 </ ErrorBoundary >
@@ -250,7 +257,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
250257 }
251258
252259 ReactNoop . render ( < App /> ) ;
253- expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Suspend! [Result]' ] ) ;
260+ expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Suspend! [Result]' , 'Loading...' ] ) ;
254261 expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
255262
256263 textResourceShouldFail = true ;
@@ -276,7 +283,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
276283 errorBoundary . current . reset ( ) ;
277284 cache . invalidate ( ) ;
278285
279- expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Suspend! [Result]' ] ) ;
286+ expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Suspend! [Result]' , 'Loading...' ] ) ;
280287 ReactNoop . expire ( 1000 ) ;
281288 await advanceTimers ( 1000 ) ;
282289 expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Promise resolved [Result]' , 'Result' ] ) ;
@@ -354,7 +361,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
354361 it ( 'can update at a higher priority while in a suspended state' , async ( ) => {
355362 function App ( props ) {
356363 return (
357- < Suspense >
364+ < Suspense fallback = { < Text text = "Loading..." /> } >
358365 < Text text = { props . highPri } />
359366 < AsyncText text = { props . lowPri } />
360367 </ Suspense >
@@ -374,6 +381,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
374381 'A' ,
375382 // Suspends
376383 'Suspend! [2]' ,
384+ 'Loading...' ,
377385 ] ) ;
378386
379387 // While we're still waiting for the low-pri update to complete, update the
@@ -393,21 +401,21 @@ describe('ReactSuspenseWithNoopRenderer', () => {
393401 it ( 'keeps working on lower priority work after being pinged' , async ( ) => {
394402 function App ( props ) {
395403 return (
396- < Suspense >
404+ < Suspense fallback = { < Text text = "Loading..." /> } >
397405 < AsyncText text = "A" />
398406 { props . showB && < Text text = "B" /> }
399407 </ Suspense >
400408 ) ;
401409 }
402410
403411 ReactNoop . render ( < App showB = { false } /> ) ;
404- expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Suspend! [A]' ] ) ;
412+ expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Suspend! [A]' , 'Loading...' ] ) ;
405413 expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
406414
407415 // Advance React's virtual time by enough to fall into a new async bucket.
408416 ReactNoop . expire ( 1200 ) ;
409417 ReactNoop . render ( < App showB = { true } /> ) ;
410- expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Suspend! [A]' , 'B' ] ) ;
418+ expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Suspend! [A]' , 'B' , 'Loading...' ] ) ;
411419 expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
412420
413421 await advanceTimers ( 0 ) ;
@@ -678,13 +686,17 @@ describe('ReactSuspenseWithNoopRenderer', () => {
678686
679687 it ( 'a Suspense component correctly handles more than one suspended child' , async ( ) => {
680688 ReactNoop . render (
681- < Suspense maxDuration = { 0 } >
689+ < Suspense maxDuration = { 0 } fallback = { < Text text = "Loading..." /> } >
682690 < AsyncText text = "A" ms = { 100 } />
683691 < AsyncText text = "B" ms = { 100 } />
684692 </ Suspense > ,
685693 ) ;
686- expect ( ReactNoop . expire ( 10000 ) ) . toEqual ( [ 'Suspend! [A]' , 'Suspend! [B]' ] ) ;
687- expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
694+ expect ( ReactNoop . expire ( 10000 ) ) . toEqual ( [
695+ 'Suspend! [A]' ,
696+ 'Suspend! [B]' ,
697+ 'Loading...' ,
698+ ] ) ;
699+ expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'Loading...' ) ] ) ;
688700
689701 await advanceTimers ( 100 ) ;
690702
@@ -724,7 +736,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
724736 it ( 'starts working on an update even if its priority falls between two suspended levels' , async ( ) => {
725737 function App ( props ) {
726738 return (
727- < Suspense maxDuration = { 10000 } >
739+ < Suspense fallback = { < Text text = "Loading..." /> } maxDuration = { 10000 } >
728740 { props . text === 'C' ? (
729741 < Text text = "C" />
730742 ) : (
@@ -737,7 +749,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
737749 // Schedule an update
738750 ReactNoop . render ( < App text = "A" /> ) ;
739751 // The update should suspend.
740- expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Suspend! [A]' ] ) ;
752+ expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Suspend! [A]' , 'Loading...' ] ) ;
741753 expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
742754
743755 // Advance time until right before it expires. This number may need to
@@ -750,7 +762,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
750762 // Schedule another low priority update.
751763 ReactNoop . render ( < App text = "B" /> ) ;
752764 // This update should also suspend.
753- expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Suspend! [B]' ] ) ;
765+ expect ( ReactNoop . flush ( ) ) . toEqual ( [ 'Suspend! [B]' , 'Loading...' ] ) ;
754766 expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ ] ) ;
755767
756768 // Schedule a high priority update. Its expiration time will fall between
@@ -773,7 +785,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
773785 it ( 'can hide a tree to unblock its surroundings' , async ( ) => {
774786 function App ( ) {
775787 return (
776- < Suspense maxDuration = { 1000 } >
788+ < Suspense fallback = { < Text text = "Fallback" /> } maxDuration = { 1000 } >
777789 { didTimeout => (
778790 < Fragment >
779791 < div hidden = { didTimeout } >
@@ -859,7 +871,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
859871
860872 function Delay ( { ms} ) {
861873 return (
862- < Suspense maxDuration = { ms } >
874+ < Suspense fallback = { < Text text = "Loading..." /> } maxDuration = { ms } >
863875 { didTimeout => {
864876 if ( didTimeout ) {
865877 // Once ms has elapsed, render null. This allows the rest of the
0 commit comments