Move sync stress tests in their own file
Dan Abramov committed
Apr 18, 2019 at 16:09 UTC
0f44e9fb9854a3abf4a3e835fa9577edb9d3f67d
3 files changed
+243
-272
src/__tests__/__snapshots__/storeStress-test.js.snap
deleted
-239
@@ -1,239 +0,0 @@
1
-// Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
-exports[`StoreStress should handle a stress test for Suspense 1`] = `
4
-[root]
5
- ▾ <Root>
6
- <X>
7
- ▾ <Suspense>
8
- <A key="a">
9
- <Y>
10
-`;
11
-
12
-exports[`StoreStress should handle a stress test for Suspense 2`] = `
13
-[root]
14
- ▾ <Root>
15
- <X>
16
- ▾ <Suspense>
17
- <A key="a">
18
- <Y>
19
-`;
20
-
21
-exports[`StoreStress should handle a stress test for Suspense 3`] = `
22
-[root]
23
- ▾ <Root>
24
- <X>
25
- ▾ <Suspense>
26
- <A key="a">
27
- <B key="b">
28
- <C key="c">
29
- <Y>
30
-`;
31
-
32
-exports[`StoreStress should handle a stress test for Suspense 4`] = `
33
-[root]
34
- ▾ <Root>
35
- <X>
36
- ▾ <Suspense>
37
- <C key="c">
38
- <B key="b">
39
- <A key="a">
40
- <Y>
41
-`;
42
-
43
-exports[`StoreStress should handle a stress test for Suspense 5`] = `
44
-[root]
45
- ▾ <Root>
46
- <X>
47
- ▾ <Suspense>
48
- <C key="c">
49
- <A key="a">
50
- <Y>
51
-`;
52
-
53
-exports[`StoreStress should handle a stress test for Suspense 6`] = `
54
-[root]
55
- ▾ <Root>
56
- <X>
57
- ▾ <Suspense>
58
- <C key="c">
59
- <A key="a">
60
- <Y>
61
-`;
62
-
63
-exports[`StoreStress should handle a stress test for Suspense 7`] = `
64
-[root]
65
- ▾ <Root>
66
- <X>
67
- ▾ <Suspense>
68
- <C key="c">
69
- <A key="a">
70
- <Y>
71
-`;
72
-
73
-exports[`StoreStress should handle a stress test for Suspense 8`] = `
74
-[root]
75
- ▾ <Root>
76
- <X>
77
- ▾ <Suspense>
78
- <A key="a">
79
- <B key="b">
80
- <Y>
81
-`;
82
-
83
-exports[`StoreStress should handle a stress test for Suspense 9`] = `
84
-[root]
85
- ▾ <Root>
86
- <X>
87
- ▾ <Suspense>
88
- <A key="a">
89
- <Y>
90
-`;
91
-
92
-exports[`StoreStress should handle a stress test for Suspense 10`] = `
93
-[root]
94
- ▾ <Root>
95
- <X>
96
- <Suspense>
97
- <Y>
98
-`;
99
-
100
-exports[`StoreStress should handle a stress test for Suspense 11`] = `
101
-[root]
102
- ▾ <Root>
103
- <X>
104
- ▾ <Suspense>
105
- <B key="b">
106
- <Y>
107
-`;
108
-
109
-exports[`StoreStress should handle a stress test for Suspense 12`] = `
110
-[root]
111
- ▾ <Root>
112
- <X>
113
- ▾ <Suspense>
114
- <A key="a">
115
- <Y>
116
-`;
117
-
118
-exports[`StoreStress should handle a stress test with different tree operations: 1: abcde 1`] = `
119
-[root]
120
- ▾ <Parent>
121
- <A key="a">
122
- <B key="b">
123
- <C key="c">
124
- <D key="d">
125
- <E key="e">
126
-`;
127
-
128
-exports[`StoreStress should handle a stress test with different tree operations: 2: abxde 1`] = `
129
-[root]
130
- ▾ <Parent>
131
- <A key="a">
132
- <B key="b">
133
- ▾ <C key="c">
134
- <X>
135
- <D key="d">
136
- <E key="e">
137
-`;
138
-
139
-exports[`StoreStress should handle stress test with reordering 1`] = `
140
-[root]
141
- ▾ <Root>
142
- <A key="a">
143
-`;
144
-
145
-exports[`StoreStress should handle stress test with reordering 2`] = `
146
-[root]
147
- ▾ <Root>
148
- <B key="b">
149
-`;
150
-
151
-exports[`StoreStress should handle stress test with reordering 3`] = `
152
-[root]
153
- ▾ <Root>
154
- <C key="c">
155
-`;
156
-
157
-exports[`StoreStress should handle stress test with reordering 4`] = `
158
-[root]
159
- ▾ <Root>
160
- <D key="d">
161
-`;
162
-
163
-exports[`StoreStress should handle stress test with reordering 5`] = `
164
-[root]
165
- ▾ <Root>
166
- <E key="e">
167
-`;
168
-
169
-exports[`StoreStress should handle stress test with reordering 6`] = `
170
-[root]
171
- ▾ <Root>
172
- <A key="a">
173
-`;
174
-
175
-exports[`StoreStress should handle stress test with reordering 7`] = `
176
-[root]
177
- ▾ <Root>
178
- <B key="b">
179
-`;
180
-
181
-exports[`StoreStress should handle stress test with reordering 8`] = `
182
-[root]
183
- ▾ <Root>
184
- <C key="c">
185
-`;
186
-
187
-exports[`StoreStress should handle stress test with reordering 9`] = `
188
-[root]
189
- ▾ <Root>
190
- <D key="d">
191
-`;
192
-
193
-exports[`StoreStress should handle stress test with reordering 10`] = `
194
-[root]
195
- ▾ <Root>
196
- <E key="e">
197
-`;
198
-
199
-exports[`StoreStress should handle stress test with reordering 11`] = `
200
-[root]
201
- ▾ <Root>
202
- <A key="a">
203
- <B key="b">
204
-`;
205
-
206
-exports[`StoreStress should handle stress test with reordering 12`] = `
207
-[root]
208
- ▾ <Root>
209
- <B key="b">
210
- <A key="a">
211
-`;
212
-
213
-exports[`StoreStress should handle stress test with reordering 13`] = `
214
-[root]
215
- ▾ <Root>
216
- <B key="b">
217
- <C key="c">
218
-`;
219
-
220
-exports[`StoreStress should handle stress test with reordering 14`] = `
221
-[root]
222
- ▾ <Root>
223
- <C key="c">
224
- <B key="b">
225
-`;
226
-
227
-exports[`StoreStress should handle stress test with reordering 15`] = `
228
-[root]
229
- ▾ <Root>
230
- <A key="a">
231
- <C key="c">
232
-`;
233
-
234
-exports[`StoreStress should handle stress test with reordering 16`] = `
235
-[root]
236
- ▾ <Root>
237
- <C key="c">
238
- <A key="a">
239
-`;
src/__tests__/__snapshots__/storeStressSync-test.js.snap
new
+239
@@ -0,0 +1,239 @@
1
+// Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 1`] = `
4
+[root]
5
+ ▾ <Root>
6
+ <X>
7
+ ▾ <Suspense>
8
+ <A key="a">
9
+ <Y>
10
+`;
11
+
12
+exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 2`] = `
13
+[root]
14
+ ▾ <Root>
15
+ <X>
16
+ ▾ <Suspense>
17
+ <A key="a">
18
+ <Y>
19
+`;
20
+
21
+exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 3`] = `
22
+[root]
23
+ ▾ <Root>
24
+ <X>
25
+ ▾ <Suspense>
26
+ <A key="a">
27
+ <B key="b">
28
+ <C key="c">
29
+ <Y>
30
+`;
31
+
32
+exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 4`] = `
33
+[root]
34
+ ▾ <Root>
35
+ <X>
36
+ ▾ <Suspense>
37
+ <C key="c">
38
+ <B key="b">
39
+ <A key="a">
40
+ <Y>
41
+`;
42
+
43
+exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 5`] = `
44
+[root]
45
+ ▾ <Root>
46
+ <X>
47
+ ▾ <Suspense>
48
+ <C key="c">
49
+ <A key="a">
50
+ <Y>
51
+`;
52
+
53
+exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 6`] = `
54
+[root]
55
+ ▾ <Root>
56
+ <X>
57
+ ▾ <Suspense>
58
+ <C key="c">
59
+ <A key="a">
60
+ <Y>
61
+`;
62
+
63
+exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 7`] = `
64
+[root]
65
+ ▾ <Root>
66
+ <X>
67
+ ▾ <Suspense>
68
+ <C key="c">
69
+ <A key="a">
70
+ <Y>
71
+`;
72
+
73
+exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 8`] = `
74
+[root]
75
+ ▾ <Root>
76
+ <X>
77
+ ▾ <Suspense>
78
+ <A key="a">
79
+ <B key="b">
80
+ <Y>
81
+`;
82
+
83
+exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 9`] = `
84
+[root]
85
+ ▾ <Root>
86
+ <X>
87
+ ▾ <Suspense>
88
+ <A key="a">
89
+ <Y>
90
+`;
91
+
92
+exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 10`] = `
93
+[root]
94
+ ▾ <Root>
95
+ <X>
96
+ <Suspense>
97
+ <Y>
98
+`;
99
+
100
+exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 11`] = `
101
+[root]
102
+ ▾ <Root>
103
+ <X>
104
+ ▾ <Suspense>
105
+ <B key="b">
106
+ <Y>
107
+`;
108
+
109
+exports[`StoreStress (Sync Mode) should handle a stress test for Suspense (Sync Mode) 12`] = `
110
+[root]
111
+ ▾ <Root>
112
+ <X>
113
+ ▾ <Suspense>
114
+ <A key="a">
115
+ <Y>
116
+`;
117
+
118
+exports[`StoreStress (Sync Mode) should handle a stress test with different tree operations (Sync Mode): 1: abcde 1`] = `
119
+[root]
120
+ ▾ <Parent>
121
+ <A key="a">
122
+ <B key="b">
123
+ <C key="c">
124
+ <D key="d">
125
+ <E key="e">
126
+`;
127
+
128
+exports[`StoreStress (Sync Mode) should handle a stress test with different tree operations (Sync Mode): 2: abxde 1`] = `
129
+[root]
130
+ ▾ <Parent>
131
+ <A key="a">
132
+ <B key="b">
133
+ ▾ <C key="c">
134
+ <X>
135
+ <D key="d">
136
+ <E key="e">
137
+`;
138
+
139
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 1`] = `
140
+[root]
141
+ ▾ <Root>
142
+ <A key="a">
143
+`;
144
+
145
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 2`] = `
146
+[root]
147
+ ▾ <Root>
148
+ <B key="b">
149
+`;
150
+
151
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 3`] = `
152
+[root]
153
+ ▾ <Root>
154
+ <C key="c">
155
+`;
156
+
157
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 4`] = `
158
+[root]
159
+ ▾ <Root>
160
+ <D key="d">
161
+`;
162
+
163
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 5`] = `
164
+[root]
165
+ ▾ <Root>
166
+ <E key="e">
167
+`;
168
+
169
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 6`] = `
170
+[root]
171
+ ▾ <Root>
172
+ <A key="a">
173
+`;
174
+
175
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 7`] = `
176
+[root]
177
+ ▾ <Root>
178
+ <B key="b">
179
+`;
180
+
181
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 8`] = `
182
+[root]
183
+ ▾ <Root>
184
+ <C key="c">
185
+`;
186
+
187
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 9`] = `
188
+[root]
189
+ ▾ <Root>
190
+ <D key="d">
191
+`;
192
+
193
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 10`] = `
194
+[root]
195
+ ▾ <Root>
196
+ <E key="e">
197
+`;
198
+
199
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 11`] = `
200
+[root]
201
+ ▾ <Root>
202
+ <A key="a">
203
+ <B key="b">
204
+`;
205
+
206
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 12`] = `
207
+[root]
208
+ ▾ <Root>
209
+ <B key="b">
210
+ <A key="a">
211
+`;
212
+
213
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 13`] = `
214
+[root]
215
+ ▾ <Root>
216
+ <B key="b">
217
+ <C key="c">
218
+`;
219
+
220
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 14`] = `
221
+[root]
222
+ ▾ <Root>
223
+ <C key="c">
224
+ <B key="b">
225
+`;
226
+
227
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 15`] = `
228
+[root]
229
+ ▾ <Root>
230
+ <A key="a">
231
+ <C key="c">
232
+`;
233
+
234
+exports[`StoreStress (Sync Mode) should handle stress test with reordering (Sync Mode) 16`] = `
235
+[root]
236
+ ▾ <Root>
237
+ <C key="c">
238
+ <A key="a">
239
+`;
src/__tests__/storeStressSync-test.js
renamed
+4
-33
@@ -1,6 +1,6 @@
1
// @flow
2
3
-describe('StoreStress', () => {
3
+describe('StoreStress (Sync Mode)', () => {
4
let React;
5
let ReactDOM;
6
let TestUtils;
@@ -29,7 +29,7 @@ describe('StoreStress', () => {
29
30
// This is a stress test for the tree mount/update/unmount traversal.
31
// It renders different trees that should produce the same output.
32
- it('should handle a stress test with different tree operations', () => {
32
+ it('should handle a stress test with different tree operations (Sync Mode)', () => {
33
let setShowX;
34
const A = () => 'a';
35
const B = () => 'b';
@@ -168,37 +168,9 @@ describe('StoreStress', () => {
168
}
169
act(() => ReactDOM.unmountComponentAtNode(container));
170
expect(print(store)).toBe('');
171
-
172
- // 7. Same as the previous step, but for Concurrent Mode.
173
- container = document.createElement('div');
174
- // $FlowFixMe
175
- let root = ReactDOM.unstable_createRoot(container);
176
- for (let i = 0; i < cases.length; i++) {
177
- // Verify mounting 'abcde'.
178
- act(() => root.render(<Parent>{cases[i]}</Parent>));
179
- expect(container.textContent).toMatch('abcde');
180
- expect(print(store)).toEqual(snapshotForABCDE);
181
-
182
- // Verify switching to 'abxde'.
183
- act(() => {
184
- setShowX(true);
185
- });
186
- expect(container.textContent).toMatch('abxde');
187
- expect(print(store)).toBe(snapshotForABXDE);
188
-
189
- // Verify switching back to 'abcde'.
190
- act(() => {
191
- setShowX(false);
192
- });
193
- expect(container.textContent).toMatch('abcde');
194
- expect(print(store)).toBe(snapshotForABCDE);
195
- // Don't unmount. Reuse the container between iterations.
196
- }
197
- act(() => root.unmount());
198
- expect(print(store)).toBe('');
171
});
172
201
- it('should handle stress test with reordering', () => {
173
+ it('should handle stress test with reordering (Sync Mode)', () => {
174
const A = () => 'a';
175
const B = () => 'b';
176
const C = () => 'c';
@@ -298,7 +270,7 @@ describe('StoreStress', () => {
270
}
271
});
272
301
- it('should handle a stress test for Suspense', async () => {
273
+ it('should handle a stress test for Suspense (Sync Mode)', async () => {
274
const A = () => 'a';
275
const B = () => 'b';
276
const C = () => 'c';
@@ -690,6 +662,5 @@ describe('StoreStress', () => {
662
expect(print(store)).toBe('');
663
}
664
}
693
- // TODO: Test Concurrent Mode
665
});
666
});