Test utils actSuspense -> actAsync
Brian Vaughn committed
May 10, 2019 at 08:27 UTC
61ab40c15c7b1b342bb4907fa88a478052173822
6 files changed
+25
-25
src/__tests__/ownersListContext-test.js
+4
-4
@@ -84,7 +84,7 @@ describe('OwnersListContext', () => {
84
return null;
85
}
86
87
- await utils.actSuspense(
87
+ await utils.actAsync(
88
() =>
89
TestRenderer.create(
90
<Contexts defaultOwnerID={parent.id}>
@@ -98,7 +98,7 @@ describe('OwnersListContext', () => {
98
expect(didFinish).toBe(true);
99
100
didFinish = false;
101
- await utils.actSuspense(
101
+ await utils.actAsync(
102
() =>
103
TestRenderer.create(
104
<Contexts defaultOwnerID={firstChild.id}>
@@ -148,7 +148,7 @@ describe('OwnersListContext', () => {
148
return null;
149
}
150
151
- await utils.actSuspense(
151
+ await utils.actAsync(
152
() =>
153
TestRenderer.create(
154
<Contexts defaultOwnerID={firstChild.id}>
@@ -190,7 +190,7 @@ describe('OwnersListContext', () => {
190
return null;
191
}
192
193
- await utils.actSuspense(
193
+ await utils.actAsync(
194
() =>
195
TestRenderer.create(
196
<Contexts defaultOwnerID={grandparent.id}>
src/__tests__/profiling-test.js
+8
-8
@@ -129,7 +129,7 @@ describe('profiling', () => {
129
const rendererID = utils.getRendererID();
130
const rootID = store.roots[0];
131
132
- await utils.actSuspense(() =>
132
+ await utils.actAsync(() =>
133
TestRenderer.create(
134
<React.Suspense fallback={null}>
135
<Suspender
@@ -145,7 +145,7 @@ describe('profiling', () => {
145
146
exportImportHelper(rendererID, rootID);
147
148
- await utils.actSuspense(() =>
148
+ await utils.actAsync(() =>
149
TestRenderer.create(
150
<React.Suspense fallback={null}>
151
<Suspender
@@ -218,7 +218,7 @@ describe('profiling', () => {
218
const rootID = store.roots[0];
219
220
for (let commitIndex = 0; commitIndex < 4; commitIndex++) {
221
- await utils.actSuspense(() => {
221
+ await utils.actAsync(() => {
222
TestRenderer.create(
223
<React.Suspense fallback={null}>
224
<Suspender
@@ -237,7 +237,7 @@ describe('profiling', () => {
237
exportImportHelper(rendererID, rootID);
238
239
for (let commitIndex = 0; commitIndex < 4; commitIndex++) {
240
- await utils.actSuspense(() => {
240
+ await utils.actAsync(() => {
241
TestRenderer.create(
242
<React.Suspense fallback={null}>
243
<Suspender
@@ -311,7 +311,7 @@ describe('profiling', () => {
311
const rootID = store.roots[0];
312
313
for (let index = 0; index < store.numElements; index++) {
314
- await utils.actSuspense(() => {
314
+ await utils.actAsync(() => {
315
const fiberID = store.getElementIDAtIndex(index);
316
if (fiberID == null) {
317
throw Error(`Unexpected null ID for element at index ${index}`);
@@ -334,7 +334,7 @@ describe('profiling', () => {
334
exportImportHelper(rendererID, rootID);
335
336
for (let index = 0; index < store.numElements; index++) {
337
- await utils.actSuspense(() => {
337
+ await utils.actAsync(() => {
338
const fiberID = store.getElementIDAtIndex(index);
339
if (fiberID == null) {
340
throw Error(`Unexpected null ID for element at index ${index}`);
@@ -413,7 +413,7 @@ describe('profiling', () => {
413
const rendererID = utils.getRendererID();
414
const rootID = store.roots[0];
415
416
- await utils.actSuspense(() =>
416
+ await utils.actAsync(() =>
417
TestRenderer.create(
418
<React.Suspense fallback={null}>
419
<Suspender
@@ -429,7 +429,7 @@ describe('profiling', () => {
429
430
exportImportHelper(rendererID, rootID);
431
432
- await utils.actSuspense(() =>
432
+ await utils.actAsync(() =>
433
TestRenderer.create(
434
<React.Suspense fallback={null}>
435
<Suspender
src/__tests__/profilingCharts-test.js
+3
-3
@@ -97,7 +97,7 @@ describe('profiling charts', () => {
97
for (let commitIndex = 0; commitIndex < 2; commitIndex++) {
98
suspenseResolved = false;
99
100
- await utils.actSuspense(
100
+ await utils.actAsync(
101
() =>
102
TestRenderer.create(
103
<React.Suspense fallback={null}>
@@ -189,7 +189,7 @@ describe('profiling charts', () => {
189
for (let commitIndex = 0; commitIndex < 2; commitIndex++) {
190
suspenseResolved = false;
191
192
- await utils.actSuspense(
192
+ await utils.actAsync(
193
() =>
194
TestRenderer.create(
195
<React.Suspense fallback={null}>
@@ -272,7 +272,7 @@ describe('profiling charts', () => {
272
for (let commitIndex = 0; commitIndex < 2; commitIndex++) {
273
suspenseResolved = false;
274
275
- await utils.actSuspense(
275
+ await utils.actAsync(
276
() =>
277
TestRenderer.create(
278
<React.Suspense fallback={null}>
src/__tests__/profilingCommitTreeBuilder-test.js
+1
-1
@@ -67,7 +67,7 @@ describe('commit tree', () => {
67
for (let commitIndex = 0; commitIndex < 4; commitIndex++) {
68
suspenseResolved = false;
69
70
- await utils.actSuspense(
70
+ await utils.actAsync(
71
() =>
72
TestRenderer.create(
73
<React.Suspense fallback={null}>
src/__tests__/treeContext-test.js
+8
-8
@@ -244,7 +244,7 @@ describe('TreeListContext', () => {
244
utils.act(() => renderer.update(<Contexts />));
245
expect(state).toMatchSnapshot('2: select second child');
246
247
- await utils.actSuspense(() =>
247
+ await utils.actAsync(() =>
248
ReactDOM.render(
249
<Grandparent>
250
<Parent />
@@ -256,7 +256,7 @@ describe('TreeListContext', () => {
256
'3: remove children (parent should now be selected)'
257
);
258
259
- await utils.actSuspense(() => ReactDOM.unmountComponentAtNode(container));
259
+ await utils.actAsync(() => ReactDOM.unmountComponentAtNode(container));
260
expect(state).toMatchSnapshot(
261
'4: unmount root (nothing should be selected)'
262
);
@@ -380,7 +380,7 @@ describe('TreeListContext', () => {
380
utils.act(() => renderer.update(<Contexts />));
381
expect(state).toMatchSnapshot('2: search for "ba"');
382
383
- await utils.actSuspense(() =>
383
+ await utils.actAsync(() =>
384
ReactDOM.render(
385
<React.Fragment>
386
<Foo />
@@ -428,7 +428,7 @@ describe('TreeListContext', () => {
428
utils.act(() => renderer.update(<Contexts />));
429
expect(state).toMatchSnapshot('3: go to second result');
430
431
- await utils.actSuspense(() =>
431
+ await utils.actAsync(() =>
432
ReactDOM.render(
433
<React.Fragment>
434
<Foo />
@@ -495,12 +495,12 @@ describe('TreeListContext', () => {
495
utils.act(() => renderer.update(<Contexts />));
496
expect(state).toMatchSnapshot('2: parent owners tree');
497
498
- await utils.actSuspense(() =>
498
+ await utils.actAsync(() =>
499
ReactDOM.render(<Grandparent count={1} />, container)
500
);
501
expect(state).toMatchSnapshot('3: remove second child');
502
503
- await utils.actSuspense(() =>
503
+ await utils.actAsync(() =>
504
ReactDOM.render(<Grandparent count={0} />, container)
505
);
506
expect(state).toMatchSnapshot('4: remove first child');
@@ -533,7 +533,7 @@ describe('TreeListContext', () => {
533
utils.act(() => renderer.update(<Contexts />));
534
expect(state).toMatchSnapshot('2: child owners tree');
535
536
- await utils.actSuspense(() => ReactDOM.render(<Parent />, container));
536
+ await utils.actAsync(() => ReactDOM.render(<Parent />, container));
537
expect(state).toMatchSnapshot('3: remove child');
538
539
let parentID = ((store.getElementIDAtIndex(0): any): number);
@@ -541,7 +541,7 @@ describe('TreeListContext', () => {
541
utils.act(() => renderer.update(<Contexts />));
542
expect(state).toMatchSnapshot('4: parent owners tree');
543
544
- await utils.actSuspense(() => ReactDOM.unmountComponentAtNode(container));
544
+ await utils.actAsync(() => ReactDOM.unmountComponentAtNode(container));
545
expect(state).toMatchSnapshot('5: unmount root');
546
547
done();
src/__tests__/utils.js
+1
-1
@@ -14,7 +14,7 @@ export function act(callback: Function): void {
14
jest.runAllTimers();
15
}
16
17
-export async function actSuspense(
17
+export async function actAsync(
18
callback: Function,
19
numTimesToFlush: number = 1
20
): Promise<void> {