Skip to content

Commit 73cde84

Browse files
committed
Fix tests
1 parent c1a1e88 commit 73cde84

30 files changed

+1866
-526
lines changed

packages/create-subscription/src/__tests__/createSubscription-test.js

+16-2
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ describe('createSubscription', () => {
268268
expect(Scheduler).toFlushAndYield(['b-1']);
269269
});
270270

271+
// @gate experimental || !enableSyncDefaultUpdates
271272
it('should ignore values emitted by a new subscribable until the commit phase', () => {
272273
const log = [];
273274

@@ -325,7 +326,13 @@ describe('createSubscription', () => {
325326
expect(log).toEqual(['Parent.componentDidMount']);
326327

327328
// Start React update, but don't finish
328-
ReactNoop.render(<Parent observed={observableB} />);
329+
if (gate(flags => flags.enableSyncDefaultUpdates)) {
330+
React.unstable_startTransition(() => {
331+
ReactNoop.render(<Parent observed={observableB} />);
332+
});
333+
} else {
334+
ReactNoop.render(<Parent observed={observableB} />);
335+
}
329336
expect(Scheduler).toFlushAndYieldThrough(['Subscriber: b-0']);
330337
expect(log).toEqual(['Parent.componentDidMount']);
331338

@@ -355,6 +362,7 @@ describe('createSubscription', () => {
355362
]);
356363
});
357364

365+
// @gate experimental || !enableSyncDefaultUpdates
358366
it('should not drop values emitted between updates', () => {
359367
const log = [];
360368

@@ -412,7 +420,13 @@ describe('createSubscription', () => {
412420
expect(log).toEqual(['Parent.componentDidMount']);
413421

414422
// Start React update, but don't finish
415-
ReactNoop.render(<Parent observed={observableB} />);
423+
if (gate(flags => flags.enableSyncDefaultUpdates)) {
424+
React.unstable_startTransition(() => {
425+
ReactNoop.render(<Parent observed={observableB} />);
426+
});
427+
} else {
428+
ReactNoop.render(<Parent observed={observableB} />);
429+
}
416430
expect(Scheduler).toFlushAndYieldThrough(['Subscriber: b-0']);
417431
expect(log).toEqual(['Parent.componentDidMount']);
418432

packages/react-art/src/__tests__/ReactART-test.js

+1
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ describe('ReactART', () => {
360360
expect(onClick2).toBeCalled();
361361
});
362362

363+
// @gate !enableSyncDefaultUpdates
363364
it('can concurrently render with a "primary" renderer while sharing context', () => {
364365
const CurrentRendererContext = React.createContext(null);
365366

packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -1865,11 +1865,21 @@ describe('ReactDOMServerPartialHydration', () => {
18651865
suspend = true;
18661866

18671867
await act(async () => {
1868-
root.render(<App />);
1869-
expect(Scheduler).toFlushAndYieldThrough(['Before']);
1870-
// This took a long time to render.
1871-
Scheduler.unstable_advanceTime(1000);
1872-
expect(Scheduler).toFlushAndYield(['After']);
1868+
if (gate(flags => flags.enableSyncDefaultUpdates)) {
1869+
React.unstable_startTransition(() => {
1870+
root.render(<App />);
1871+
});
1872+
1873+
expect(Scheduler).toFlushAndYieldThrough(['Before', 'After']);
1874+
} else {
1875+
root.render(<App />);
1876+
1877+
expect(Scheduler).toFlushAndYieldThrough(['Before']);
1878+
// This took a long time to render.
1879+
Scheduler.unstable_advanceTime(1000);
1880+
expect(Scheduler).toFlushAndYield(['After']);
1881+
}
1882+
18731883
// This will cause us to skip the second row completely.
18741884
});
18751885

packages/react-dom/src/events/__tests__/DOMPluginEventSystem-test.internal.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,13 @@ describe('DOMPluginEventSystem', () => {
19341934
log.length = 0;
19351935

19361936
// Increase counter
1937-
root.render(<Test counter={1} />);
1937+
if (gate(flags => flags.enableSyncDefaultUpdates)) {
1938+
React.unstable_startTransition(() => {
1939+
root.render(<Test counter={1} />);
1940+
});
1941+
} else {
1942+
root.render(<Test counter={1} />);
1943+
}
19381944
// Yield before committing
19391945
expect(Scheduler).toFlushAndYieldThrough(['Test']);
19401946

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

+8-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ describe('ReactSuspenseList', () => {
4545
return Component;
4646
}
4747

48+
// @gate experimental || !enableSyncDefaultUpdates
4849
it('appends rendering tasks to the end of the priority queue', async () => {
4950
const A = createAsyncText('A');
5051
const B = createAsyncText('B');
@@ -63,7 +64,13 @@ describe('ReactSuspenseList', () => {
6364
root.render(<App show={false} />);
6465
expect(Scheduler).toFlushAndYield([]);
6566

66-
root.render(<App show={true} />);
67+
if (gate(flags => flags.enableSyncDefaultUpdates)) {
68+
React.unstable_startTransition(() => {
69+
root.render(<App show={true} />);
70+
});
71+
} else {
72+
root.render(<App show={true} />);
73+
}
6774
expect(Scheduler).toFlushAndYield([
6875
'Suspend! [A]',
6976
'Suspend! [B]',

0 commit comments

Comments
 (0)