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

This commit is contained in:
Sebastian Markbåge 2019-03-18 15:21:49 -07:00 committed by GitHub
parent 42c3c967d1
commit 1e3364e764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 0 deletions

View File

@ -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(
<React.Suspense maxDuration={1000} fallback={'Loading'}>
Initial
</React.Suspense>,
);
Scheduler.flushAll();
expect(container.textContent).toBe('Initial');
root.render(
<React.Suspense maxDuration={1000} fallback={'Loading'}>
<Suspend />
</React.Suspense>,
);
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');
});
});
});