@samitouri / QOS-React / commits / 1e3364e764

Test that we don't suspend when disabling yielding (#15143)

Sebastian Markbåge committed Mar 18, 2019 at 15:21 UTC 1e3364e764ff8c90c082b90f688e6553c3811366
1 file changed +31
packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.internal.js
+31
@@ -710,5 +710,36 @@ describe('ReactDOMFiberAsync', () => {
710 // everything without yielding when the flag is on.
711 expect(Scheduler).toHaveYielded(['A', 'B', 'C']);
712 });
713 +
714 + it('wont suspend during a render if yielding is disabled', () => {
715 + let p = new Promise(resolve => {});
716 +
717 + function Suspend() {
718 + throw p;
719 + }
720 +
721 + let root = ReactDOM.unstable_createRoot(container);
722 + root.render(
723 + <React.Suspense maxDuration={1000} fallback={'Loading'}>
724 + Initial
725 + </React.Suspense>,
726 + );
727 +
728 + Scheduler.flushAll();
729 + expect(container.textContent).toBe('Initial');
730 +
731 + root.render(
732 + <React.Suspense maxDuration={1000} fallback={'Loading'}>
733 + <Suspend />
734 + </React.Suspense>,
735 + );
736 +
737 + expect(Scheduler).toHaveYielded([]);
738 +
739 + Scheduler.flushAll();
740 +
741 + // This should have flushed to the DOM even though we haven't ran the timers.
742 + expect(container.textContent).toBe('Loading');
743 + });
744 });
745 });