({step})
| 631 | const {Suspense} = React; |
| 632 | |
| 633 | function App({step}) { |
| 634 | return ( |
| 635 | <Suspense fallback={<Text text="Loading..." />}> |
| 636 | <AsyncText text={'A' + step} /> |
| 637 | <Text text="B" /> |
| 638 | <Text text="C" /> |
| 639 | </Suspense> |
| 640 | ); |
| 641 | } |
| 642 | |
| 643 | const root = ReactNoop.createRoot(); |
| 644 | await act(async () => { |
| 645 | await resolveText('A0'); |
| 646 | root.render(<App step={0} />); |
| 647 | }); |
| 648 | assertLog(['A0', 'B', 'C']); |
| 649 | expect(root).toMatchRenderedOutput('A0BC'); |
| 650 | |
| 651 | await act(async () => { |
| 652 | React.startTransition(() => { |
| 653 | root.render(<App step={1} />); |
| 654 | }); |
| 655 | await waitForAll([ |
| 656 | 'Suspend! [A1]', |
| 657 | // pre-warming |
| 658 | 'B', |
| 659 | 'C', |
| 660 | // end pre-warming |
| 661 | 'Loading...', |
| 662 | ]); |
| 663 | |
| 664 | // Lots of time elapses before the promise resolves |
| 665 | Scheduler.unstable_advanceTime(10000); |
| 666 | await resolveText('A1'); |
| 667 | assertLog(['Promise resolved [A1]']); |
| 668 | |
| 669 | await waitFor(['A1']); |
| 670 | expect(root).toMatchRenderedOutput('A0BC'); |
| 671 | |
| 672 | // Lots more time elapses. We're CPU-bound now, so we should treat this |
| 673 | // as starvation. |
| 674 | Scheduler.unstable_advanceTime(10000); |
| 675 | |
| 676 | // The rest of the update finishes without yielding. |
| 677 | await waitFor([], { |
| 678 | additionalLogsAfterAttemptingToYield: ['B', 'C'], |
| 679 | }); |
| 680 | }); |
| 681 | }); |
| 682 | |
| 683 | it('flushSync should not affect expired work', async () => { |
| 684 | let setA; |
nothing calls this directly
no test coverage detected