Fixed broken Profiler test (#19894)
Brian Vaughn committed
Sep 23, 2020 at 15:33 UTC
c6917346ff9f7ebdfbe11b73a72c82153ac704ec
1 file changed
+12
-15
packages/react/src/__tests__/ReactProfiler-test.internal.js
+12
-15
@@ -3477,16 +3477,16 @@ describe('Profiler', () => {
3477
}
3478
}
3479
3480
- const onPostCommit = jest.fn(() => {
3481
- Scheduler.unstable_yieldValue('onPostCommit');
3480
+ const onCommit = jest.fn(() => {
3481
+ Scheduler.unstable_yieldValue('onCommit');
3482
});
3483
- ReactNoop.act(async () => {
3483
+ await ReactNoop.act(async () => {
3484
SchedulerTracing.unstable_trace(
3485
interaction.name,
3486
Scheduler.unstable_now(),
3487
() => {
3488
ReactNoop.render(
3489
- <React.Profiler id="test-profiler" onPostCommit={onPostCommit}>
3489
+ <React.Profiler id="test-profiler" onCommit={onCommit}>
3490
<React.Suspense fallback={<Text text="Loading..." />}>
3491
<AsyncText text="Async" ms={20000} />
3492
</React.Suspense>
@@ -3511,13 +3511,13 @@ describe('Profiler', () => {
3511
'Text [Loading...]',
3512
'Text [Sync]',
3513
'Monkey',
3514
- 'onPostCommit',
3514
+ 'onCommit',
3515
]);
3516
// Should have committed the placeholder.
3517
expect(ReactNoop.getChildrenAsJSX()).toEqual('Loading...Sync');
3518
- expect(onPostCommit).toHaveBeenCalledTimes(1);
3518
+ expect(onCommit).toHaveBeenCalledTimes(1);
3519
3520
- let call = onPostCommit.mock.calls[0];
3520
+ let call = onCommit.mock.calls[0];
3521
expect(call[0]).toEqual('test-profiler');
3522
expect(call[4]).toMatchInteractions(
3523
ReactFeatureFlags.enableSchedulerTracing ? [interaction] : [],
@@ -3528,20 +3528,17 @@ describe('Profiler', () => {
3528
3529
// An unrelated update in the middle shouldn't affect things...
3530
monkey.current.forceUpdate();
3531
- expect(Scheduler).toFlushAndYield(['Monkey', 'onPostCommit']);
3532
- expect(onPostCommit).toHaveBeenCalledTimes(2);
3531
+ expect(Scheduler).toFlushAndYield(['Monkey', 'onCommit']);
3532
+ expect(onCommit).toHaveBeenCalledTimes(2);
3533
3534
// Once the promise resolves, we render the suspended view
3535
await awaitableAdvanceTimers(20000);
3536
expect(Scheduler).toHaveYielded(['Promise resolved [Async]']);
3537
- expect(Scheduler).toFlushAndYield([
3538
- 'AsyncText [Async]',
3539
- 'onPostCommit',
3540
- ]);
3537
+ expect(Scheduler).toFlushAndYield(['AsyncText [Async]', 'onCommit']);
3538
expect(ReactNoop.getChildrenAsJSX()).toEqual('AsyncSync');
3542
- expect(onPostCommit).toHaveBeenCalledTimes(3);
3539
+ expect(onCommit).toHaveBeenCalledTimes(3);
3540
3544
- call = onPostCommit.mock.calls[2];
3541
+ call = onCommit.mock.calls[2];
3542
expect(call[0]).toEqual('test-profiler');
3543
expect(call[4]).toMatchInteractions(
3544
ReactFeatureFlags.enableSchedulerTracing ? [interaction] : [],