Skip to content

Commit

Permalink
Test that we don't suspend when disabling yielding (#15143)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebmarkbage authored Mar 18, 2019
1 parent 42c3c96 commit 1e3364e
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
});

0 comments on commit 1e3364e

Please sign in to comment.