From 180f0dd7578e6747cca7b351857ce496e18476ae Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Sun, 4 Nov 2018 14:58:30 -0800 Subject: [PATCH] Add failing test for stuck Suspense fallback --- .../__tests__/ReactSuspense-test.internal.js | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js b/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js index c101d905984e6..444663ad346d0 100644 --- a/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js +++ b/packages/react-reconciler/src/__tests__/ReactSuspense-test.internal.js @@ -690,5 +690,33 @@ describe('ReactSuspense', () => { ); expect(mounts).toBe(1); }); + + it('does not get stuck with fallback in concurrent mode for a large delay', () => { + function App(props) { + return ( + }> + + + + ); + } + + const root = ReactTestRenderer.create(, { + unstable_isConcurrent: true, + }); + + expect(root).toFlushAndYield([ + 'Suspend! [Child 1]', + 'Suspend! [Child 2]', + 'Loading...', + ]); + jest.advanceTimersByTime(1000); + expect(ReactTestRenderer).toHaveYielded(['Promise resolved [Child 1]']); + expect(root).toFlushAndYield(['Child 1', 'Suspend! [Child 2]']); + jest.advanceTimersByTime(6000); + expect(ReactTestRenderer).toHaveYielded(['Promise resolved [Child 2]']); + expect(root).toFlushAndYield(['Child 1', 'Child 2']); + expect(root).toMatchRenderedOutput(['Child 1', 'Child 2'].join('')); + }); }); });