Skip to content

Commit 5a98cd2

Browse files
committed
Fix more tests
1 parent 556ddbf commit 5a98cd2

File tree

8 files changed

+22
-76
lines changed

8 files changed

+22
-76
lines changed

packages/react-reconciler/src/__tests__/ReactExpiration-test.js

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -508,13 +508,9 @@ describe('ReactExpiration', () => {
508508

509509
// First demonstrate what happens when there's no starvation
510510
await act(async () => {
511-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
512-
React.startTransition(() => {
513-
updateNormalPri();
514-
});
515-
} else {
511+
React.startTransition(() => {
516512
updateNormalPri();
517-
}
513+
});
518514
expect(Scheduler).toFlushAndYieldThrough(['Sync pri: 0']);
519515
updateSyncPri();
520516
expect(Scheduler).toHaveYielded(['Sync pri: 1', 'Normal pri: 0']);
@@ -532,13 +528,9 @@ describe('ReactExpiration', () => {
532528

533529
// Do the same thing, but starve the first update
534530
await act(async () => {
535-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
536-
React.startTransition(() => {
537-
updateNormalPri();
538-
});
539-
} else {
531+
React.startTransition(() => {
540532
updateNormalPri();
541-
}
533+
});
542534
expect(Scheduler).toFlushAndYieldThrough(['Sync pri: 1']);
543535

544536
// This time, a lot of time has elapsed since the normal pri update

packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,10 @@ describe('ReactHooksWithNoopRenderer', () => {
171171

172172
// Schedule some updates
173173
act(() => {
174-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
175-
React.startTransition(() => {
176-
counter.current.updateCount(1);
177-
counter.current.updateCount(count => count + 10);
178-
});
179-
} else {
174+
React.startTransition(() => {
180175
counter.current.updateCount(1);
181176
counter.current.updateCount(count => count + 10);
182-
}
177+
});
183178

184179
// Partially flush without committing
185180
expect(Scheduler).toFlushAndYieldThrough(['Count: 11']);
@@ -815,13 +810,9 @@ describe('ReactHooksWithNoopRenderer', () => {
815810
ReactNoop.discreteUpdates(() => {
816811
setRow(5);
817812
});
818-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
819-
React.startTransition(() => {
820-
setRow(20);
821-
});
822-
} else {
813+
React.startTransition(() => {
823814
setRow(20);
824-
}
815+
});
825816
});
826817
expect(Scheduler).toHaveYielded(['Up', 'Down']);
827818
expect(root).toMatchRenderedOutput(<span prop="Down" />);

packages/react-reconciler/src/__tests__/ReactIncremental-test.js

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -215,50 +215,30 @@ describe('ReactIncremental', () => {
215215
ReactNoop.render(<Foo />);
216216
expect(Scheduler).toFlushWithoutYielding();
217217

218-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
219-
React.startTransition(() => {
220-
inst.setState(
221-
() => {
222-
Scheduler.unstable_yieldValue('setState1');
223-
return {text: 'bar'};
224-
},
225-
() => Scheduler.unstable_yieldValue('callback1'),
226-
);
227-
});
228-
} else {
218+
React.startTransition(() => {
229219
inst.setState(
230220
() => {
231221
Scheduler.unstable_yieldValue('setState1');
232222
return {text: 'bar'};
233223
},
234224
() => Scheduler.unstable_yieldValue('callback1'),
235225
);
236-
}
226+
});
237227

238228
// Flush part of the work
239229
expect(Scheduler).toFlushAndYieldThrough(['setState1']);
240230

241231
// This will abort the previous work and restart
242232
ReactNoop.flushSync(() => ReactNoop.render(<Foo />));
243-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
244-
React.startTransition(() => {
245-
inst.setState(
246-
() => {
247-
Scheduler.unstable_yieldValue('setState2');
248-
return {text2: 'baz'};
249-
},
250-
() => Scheduler.unstable_yieldValue('callback2'),
251-
);
252-
});
253-
} else {
233+
React.startTransition(() => {
254234
inst.setState(
255235
() => {
256236
Scheduler.unstable_yieldValue('setState2');
257237
return {text2: 'baz'};
258238
},
259239
() => Scheduler.unstable_yieldValue('callback2'),
260240
);
261-
}
241+
});
262242

263243
// Flush the rest of the work which now includes the low priority
264244
expect(Scheduler).toFlushAndYield([

packages/react-reconciler/src/__tests__/ReactSuspenseList-test.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,13 +2549,9 @@ describe('ReactSuspenseList', () => {
25492549

25502550
await act(async () => {
25512551
// Add a few items at the end.
2552-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
2553-
React.startTransition(() => {
2554-
updateLowPri(true);
2555-
});
2556-
} else {
2552+
React.startTransition(() => {
25572553
updateLowPri(true);
2558-
}
2554+
});
25592555

25602556
// Flush partially through.
25612557
expect(Scheduler).toFlushAndYieldThrough(['B', 'C']);

packages/react-reconciler/src/__tests__/ReactSuspenseWithNoopRenderer-test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3796,7 +3796,6 @@ describe('ReactSuspenseWithNoopRenderer', () => {
37963796
});
37973797

37983798
// @gate enableLegacyCache
3799-
// @gate !enableSyncDefaultUpdates
38003799
it('regression: ping at high priority causes update to be dropped', async () => {
38013800
const {useState, useTransition} = React;
38023801

@@ -3863,10 +3862,9 @@ describe('ReactSuspenseWithNoopRenderer', () => {
38633862
});
38643863

38653864
expect(Scheduler).toFlushAndYield([
3866-
'B',
38673865
'Suspend! [A1]',
38683866
'Loading...',
3869-
3867+
'B',
38703868
'Suspend! [A2]',
38713869
'Loading...',
38723870
'Suspend! [B2]',
@@ -3882,6 +3880,7 @@ describe('ReactSuspenseWithNoopRenderer', () => {
38823880
await resolveText('A1');
38833881
expect(Scheduler).toFlushAndYield([
38843882
'A1',
3883+
'B',
38853884
'Suspend! [A2]',
38863885
'Loading...',
38873886
'Suspend! [B2]',

packages/react-reconciler/src/__tests__/useMutableSource-test.internal.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,9 @@ describe('useMutableSource', () => {
454454

455455
// Changing values should schedule an update with React.
456456
// Start working on this update but don't finish it.
457-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
458-
React.startTransition(() => {
459-
source.value = 'two';
460-
});
461-
} else {
457+
React.startTransition(() => {
462458
source.value = 'two';
463-
}
459+
});
464460
expect(Scheduler).toFlushAndYieldThrough(['a:two']);
465461

466462
// Re-renders that occur before the update is processed

packages/react/src/__tests__/ReactProfiler-test.internal.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,13 +1065,9 @@ describe(`onRender`, () => {
10651065

10661066
// Render a partially update, but don't finish.
10671067
// This partial render will take 10ms of actual render time.
1068-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
1069-
React.startTransition(() => {
1070-
first.setState({renderTime: 10});
1071-
});
1072-
} else {
1068+
React.startTransition(() => {
10731069
first.setState({renderTime: 10});
1074-
}
1070+
});
10751071
expect(Scheduler).toFlushAndYieldThrough(['FirstComponent:10']);
10761072
expect(callback).toHaveBeenCalledTimes(0);
10771073

packages/use-subscription/src/__tests__/useSubscription-test.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,9 @@ describe('useSubscription', () => {
439439

440440
// Start React update, but don't finish
441441
act(() => {
442-
if (gate(flags => flags.enableSyncDefaultUpdates)) {
443-
React.startTransition(() => {
444-
renderer.update(<Parent observed={observableB} />);
445-
});
446-
} else {
442+
React.startTransition(() => {
447443
renderer.update(<Parent observed={observableB} />);
448-
}
444+
});
449445
expect(Scheduler).toFlushAndYieldThrough(['Child: b-0']);
450446
expect(log).toEqual([]);
451447

0 commit comments

Comments
 (0)