From 1e3364e764ff8c90c082b90f688e6553c3811366 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Markb=C3=A5ge?= Date: Mon, 18 Mar 2019 15:21:49 -0700 Subject: [PATCH] Test that we don't suspend when disabling yielding (#15143) --- .../ReactDOMFiberAsync-test.internal.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.internal.js b/packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.internal.js index c3e83a5795400..68e9ae3e722f7 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.internal.js +++ b/packages/react-dom/src/__tests__/ReactDOMFiberAsync-test.internal.js @@ -710,5 +710,36 @@ describe('ReactDOMFiberAsync', () => { // everything without yielding when the flag is on. expect(Scheduler).toHaveYielded(['A', 'B', 'C']); }); + + it('wont suspend during a render if yielding is disabled', () => { + let p = new Promise(resolve => {}); + + function Suspend() { + throw p; + } + + let root = ReactDOM.unstable_createRoot(container); + root.render( + + Initial + , + ); + + Scheduler.flushAll(); + expect(container.textContent).toBe('Initial'); + + root.render( + + + , + ); + + expect(Scheduler).toHaveYielded([]); + + Scheduler.flushAll(); + + // This should have flushed to the DOM even though we haven't ran the timers. + expect(container.textContent).toBe('Loading'); + }); }); });