Skip to content

Commit 1e3364e

Browse files
authored
Test that we don't suspend when disabling yielding (#15143)
1 parent 42c3c96 commit 1e3364e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.internal.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,5 +710,36 @@ describe('ReactDOMFiberAsync', () => {
710710
// everything without yielding when the flag is on.
711711
expect(Scheduler).toHaveYielded(['A', 'B', 'C']);
712712
});
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+
});
713744
});
714745
});

0 commit comments

Comments
 (0)