From 0f44e9fb9854a3abf4a3e835fa9577edb9d3f67d Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 18 Apr 2019 16:09:45 +0100 Subject: [PATCH] Move sync stress tests in their own file --- .../__snapshots__/storeStress-test.js.snap | 239 ------------------ .../storeStressSync-test.js.snap | 239 ++++++++++++++++++ ...Stress-test.js => storeStressSync-test.js} | 37 +-- 3 files changed, 243 insertions(+), 272 deletions(-) delete mode 100644 src/__tests__/__snapshots__/storeStress-test.js.snap create mode 100644 src/__tests__/__snapshots__/storeStressSync-test.js.snap rename src/__tests__/{storeStress-test.js => storeStressSync-test.js} (94%) diff --git a/src/__tests__/__snapshots__/storeStress-test.js.snap b/src/__tests__/__snapshots__/storeStress-test.js.snap deleted file mode 100644 index 9deb51fb38..0000000000 --- a/src/__tests__/__snapshots__/storeStress-test.js.snap +++ /dev/null @@ -1,239 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`StoreStress should handle a stress test for Suspense 1`] = ` -[root] - ▾ - - ▾ - - -`; - -exports[`StoreStress should handle a stress test for Suspense 2`] = ` -[root] - ▾ - - ▾ - - -`; - -exports[`StoreStress should handle a stress test for Suspense 3`] = ` -[root] - ▾ - - ▾ - - - - -`; - -exports[`StoreStress should handle a stress test for Suspense 4`] = ` -[root] - ▾ - - ▾ - - - - -`; - -exports[`StoreStress should handle a stress test for Suspense 5`] = ` -[root] - ▾ - - ▾ - - - -`; - -exports[`StoreStress should handle a stress test for Suspense 6`] = ` -[root] - ▾ - - ▾ - - - -`; - -exports[`StoreStress should handle a stress test for Suspense 7`] = ` -[root] - ▾ - - ▾ - - - -`; - -exports[`StoreStress should handle a stress test for Suspense 8`] = ` -[root] - ▾ - - ▾ - - - -`; - -exports[`StoreStress should handle a stress test for Suspense 9`] = ` -[root] - ▾ - - ▾ - - -`; - -exports[`StoreStress should handle a stress test for Suspense 10`] = ` -[root] - ▾ - - - -`; - -exports[`StoreStress should handle a stress test for Suspense 11`] = ` -[root] - ▾ - - ▾ - - -`; - -exports[`StoreStress should handle a stress test for Suspense 12`] = ` -[root] - ▾ - - ▾ - - -`; - -exports[`StoreStress should handle a stress test with different tree operations: 1: abcde 1`] = ` -[root] - ▾ - - - - - -`; - -exports[`StoreStress should handle a stress test with different tree operations: 2: abxde 1`] = ` -[root] - ▾ - - - ▾ - - - -`; - -exports[`StoreStress should handle stress test with reordering 1`] = ` -[root] - ▾ - -`; - -exports[`StoreStress should handle stress test with reordering 2`] = ` -[root] - ▾ - -`; - -exports[`StoreStress should handle stress test with reordering 3`] = ` -[root] - ▾ - -`; - -exports[`StoreStress should handle stress test with reordering 4`] = ` -[root] - ▾ - -`; - -exports[`StoreStress should handle stress test with reordering 5`] = ` -[root] - ▾ - -`; - -exports[`StoreStress should handle stress test with reordering 6`] = ` -[root] - ▾ - -`; - -exports[`StoreStress should handle stress test with reordering 7`] = ` -[root] - ▾ - -`; - -exports[`StoreStress should handle stress test with reordering 8`] = ` -[root] - ▾ - -`; - -exports[`StoreStress should handle stress test with reordering 9`] = ` -[root] - ▾ - -`; - -exports[`StoreStress should handle stress test with reordering 10`] = ` -[root] - ▾ - -`; - -exports[`StoreStress should handle stress test with reordering 11`] = ` -[root] - ▾ - - -`; - -exports[`StoreStress should handle stress test with reordering 12`] = ` -[root] - ▾ - - -`; - -exports[`StoreStress should handle stress test with reordering 13`] = ` -[root] - ▾ - - -`; - -exports[`StoreStress should handle stress test with reordering 14`] = ` -[root] - ▾ - - -`; - -exports[`StoreStress should handle stress test with reordering 15`] = ` -[root] - ▾ - - -`; - -exports[`StoreStress should handle stress test with reordering 16`] = ` -[root] - ▾ - - -`; diff --git a/src/__tests__/__snapshots__/storeStressSync-test.js.snap b/src/__tests__/__snapshots__/storeStressSync-test.js.snap new file mode 100644 index 0000000000..d4a4f7e466 --- /dev/null +++ b/src/__tests__/__snapshots__/storeStressSync-test.js.snap @@ -0,0 +1,239 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 1`] = ` +[root] + ▾ + + ▾ + + +`; + +exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 2`] = ` +[root] + ▾ + + ▾ + + +`; + +exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 3`] = ` +[root] + ▾ + + ▾ + + + + +`; + +exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 4`] = ` +[root] + ▾ + + ▾ + + + + +`; + +exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 5`] = ` +[root] + ▾ + + ▾ + + + +`; + +exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 6`] = ` +[root] + ▾ + + ▾ + + + +`; + +exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 7`] = ` +[root] + ▾ + + ▾ + + + +`; + +exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 8`] = ` +[root] + ▾ + + ▾ + + + +`; + +exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 9`] = ` +[root] + ▾ + + ▾ + + +`; + +exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 10`] = ` +[root] + ▾ + + + +`; + +exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 11`] = ` +[root] + ▾ + + ▾ + + +`; + +exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 12`] = ` +[root] + ▾ + + ▾ + + +`; + +exports[`StoreStress (Sync Mode) should handle a stress test with different tree operations (Sync Mode): 1: abcde 1`] = ` +[root] + ▾ + + + + + +`; + +exports[`StoreStress (Sync Mode) should handle a stress test with different tree operations (Sync Mode): 2: abxde 1`] = ` +[root] + ▾ + + + ▾ + + + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 1`] = ` +[root] + ▾ + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 2`] = ` +[root] + ▾ + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 3`] = ` +[root] + ▾ + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 4`] = ` +[root] + ▾ + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 5`] = ` +[root] + ▾ + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 6`] = ` +[root] + ▾ + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 7`] = ` +[root] + ▾ + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 8`] = ` +[root] + ▾ + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 9`] = ` +[root] + ▾ + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 10`] = ` +[root] + ▾ + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 11`] = ` +[root] + ▾ + + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 12`] = ` +[root] + ▾ + + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 13`] = ` +[root] + ▾ + + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 14`] = ` +[root] + ▾ + + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 15`] = ` +[root] + ▾ + + +`; + +exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 16`] = ` +[root] + ▾ + + +`; diff --git a/src/__tests__/storeStress-test.js b/src/__tests__/storeStressSync-test.js similarity index 94% rename from src/__tests__/storeStress-test.js rename to src/__tests__/storeStressSync-test.js index 12e111adf5..30f48d9a26 100644 --- a/src/__tests__/storeStress-test.js +++ b/src/__tests__/storeStressSync-test.js @@ -1,6 +1,6 @@ // @flow -describe('StoreStress', () => { +describe('StoreStress (Sync Mode)', () => { let React; let ReactDOM; let TestUtils; @@ -29,7 +29,7 @@ describe('StoreStress', () => { // This is a stress test for the tree mount/update/unmount traversal. // It renders different trees that should produce the same output. - it('should handle a stress test with different tree operations', () => { + it('should handle a stress test with different tree operations (Sync Mode)', () => { let setShowX; const A = () => 'a'; const B = () => 'b'; @@ -168,37 +168,9 @@ describe('StoreStress', () => { } act(() => ReactDOM.unmountComponentAtNode(container)); expect(print(store)).toBe(''); - - // 7. Same as the previous step, but for Concurrent Mode. - container = document.createElement('div'); - // $FlowFixMe - let root = ReactDOM.unstable_createRoot(container); - for (let i = 0; i < cases.length; i++) { - // Verify mounting 'abcde'. - act(() => root.render({cases[i]})); - expect(container.textContent).toMatch('abcde'); - expect(print(store)).toEqual(snapshotForABCDE); - - // Verify switching to 'abxde'. - act(() => { - setShowX(true); - }); - expect(container.textContent).toMatch('abxde'); - expect(print(store)).toBe(snapshotForABXDE); - - // Verify switching back to 'abcde'. - act(() => { - setShowX(false); - }); - expect(container.textContent).toMatch('abcde'); - expect(print(store)).toBe(snapshotForABCDE); - // Don't unmount. Reuse the container between iterations. - } - act(() => root.unmount()); - expect(print(store)).toBe(''); }); - it('should handle stress test with reordering', () => { + it('should handle stress test with reordering (Sync Mode)', () => { const A = () => 'a'; const B = () => 'b'; const C = () => 'c'; @@ -298,7 +270,7 @@ describe('StoreStress', () => { } }); - it('should handle a stress test for Suspense', async () => { + it('should handle a stress test for Suspense (Sync Mode)', async () => { const A = () => 'a'; const B = () => 'b'; const C = () => 'c'; @@ -690,6 +662,5 @@ describe('StoreStress', () => { expect(print(store)).toBe(''); } } - // TODO: Test Concurrent Mode }); });