@@ -575,7 +575,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
575575 < Suspense fallback = "Loading..." >
576576 < Text text = "Sibling" />
577577 { shouldSuspend ? (
578- < AsyncText ms = { 10000 } text = { 'Step ' + step } />
578+ < AsyncText text = { 'Step ' + step } />
579579 ) : (
580580 < Text text = { 'Step ' + step } />
581581 ) }
@@ -2595,7 +2595,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
25952595 }
25962596 return (
25972597 < Suspense fallback = { < Text text = "Loading..." /> } >
2598- < AsyncText text = { page } ms = { 5000 } />
2598+ < AsyncText text = { page } />
25992599 </ Suspense >
26002600 ) ;
26012601 }
@@ -2616,8 +2616,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
26162616 } ) ;
26172617
26182618 // Later we load the data.
2619- Scheduler . unstable_advanceTime ( 5000 ) ;
2620- await advanceTimers ( 5000 ) ;
2619+ await resolveText ( 'A' ) ;
26212620 expect ( Scheduler ) . toHaveYielded ( [ 'Promise resolved [A]' ] ) ;
26222621 expect ( Scheduler ) . toFlushAndYield ( [ 'A' ] ) ;
26232622 expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'A' ) ] ) ;
@@ -2635,8 +2634,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
26352634 } ) ;
26362635
26372636 // Later we load the data.
2638- Scheduler . unstable_advanceTime ( 3000 ) ;
2639- await advanceTimers ( 3000 ) ;
2637+ await resolveText ( 'B' ) ;
26402638 expect ( Scheduler ) . toHaveYielded ( [ 'Promise resolved [B]' ] ) ;
26412639 expect ( Scheduler ) . toFlushAndYield ( [ 'B' ] ) ;
26422640 expect ( ReactNoop . getChildren ( ) ) . toEqual ( [ span ( 'B' ) ] ) ;
@@ -2754,12 +2752,14 @@ describe('ReactSuspenseWithNoopRenderer', () => {
27542752 ) ;
27552753 } ) ;
27562754
2755+ // TODO: This test is specifically about avoided commits that suspend for a
2756+ // JND. We may remove this behavior.
27572757 it ( "suspended commit remains suspended even if there's another update at same expiration" , async ( ) => {
27582758 // Regression test
27592759 function App ( { text} ) {
27602760 return (
27612761 < Suspense fallback = "Loading..." >
2762- < AsyncText ms = { 2000 } text = { text } />
2762+ < AsyncText text = { text } />
27632763 </ Suspense >
27642764 ) ;
27652765 }
@@ -2768,34 +2768,28 @@ describe('ReactSuspenseWithNoopRenderer', () => {
27682768 await ReactNoop . act ( async ( ) => {
27692769 root . render ( < App text = "Initial" /> ) ;
27702770 } ) ;
2771+ expect ( Scheduler ) . toHaveYielded ( [ 'Suspend! [Initial]' ] ) ;
27712772
27722773 // Resolve initial render
27732774 await ReactNoop . act ( async ( ) => {
2774- Scheduler . unstable_advanceTime ( 2000 ) ;
2775- await advanceTimers ( 2000 ) ;
2775+ await resolveText ( 'Initial' ) ;
27762776 } ) ;
2777- expect ( Scheduler ) . toHaveYielded ( [
2778- 'Suspend! [Initial]' ,
2779- 'Promise resolved [Initial]' ,
2780- 'Initial' ,
2781- ] ) ;
2777+ expect ( Scheduler ) . toHaveYielded ( [ 'Promise resolved [Initial]' , 'Initial' ] ) ;
27822778 expect ( root ) . toMatchRenderedOutput ( < span prop = "Initial" /> ) ;
27832779
2784- // Update. Since showing a fallback would hide content that's already
2785- // visible, it should suspend for a bit without committing.
27862780 await ReactNoop . act ( async ( ) => {
2781+ // Update. Since showing a fallback would hide content that's already
2782+ // visible, it should suspend for a JND without committing.
27872783 root . render ( < App text = "First update" /> ) ;
2788-
27892784 expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [First update]' ] ) ;
2785+
27902786 // Should not display a fallback
27912787 expect ( root ) . toMatchRenderedOutput ( < span prop = "Initial" /> ) ;
2792- } ) ;
27932788
2794- // Update again. This should also suspend for a bit.
2795- await ReactNoop . act ( async ( ) => {
2789+ // Update again. This should also suspend for a JND.
27962790 root . render ( < App text = "Second update" /> ) ;
2797-
27982791 expect ( Scheduler ) . toFlushAndYield ( [ 'Suspend! [Second update]' ] ) ;
2792+
27992793 // Should not display a fallback
28002794 expect ( root ) . toMatchRenderedOutput ( < span prop = "Initial" /> ) ;
28012795 } ) ;
@@ -3989,9 +3983,6 @@ describe('ReactSuspenseWithNoopRenderer', () => {
39893983 await ReactNoop . act ( async ( ) => {
39903984 root . render ( < App show = { true } /> ) ;
39913985 } ) ;
3992- // TODO: `act` should have already flushed the placeholder, so this
3993- // runAllTimers call should be unnecessary.
3994- jest . runAllTimers ( ) ;
39953986 expect ( Scheduler ) . toHaveYielded ( [ 'Suspend! [Async]' , 'Loading...' ] ) ;
39963987 expect ( root ) . toMatchRenderedOutput (
39973988 < >
0 commit comments