Skip to content

Commit 056a3ab

Browse files
author
Brian Vaughn
committed
Updated tests
1 parent 1b613de commit 056a3ab

File tree

91 files changed

+419
-794
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+419
-794
lines changed

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

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

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

@@ -327,7 +326,7 @@ describe('createSubscription', () => {
327326

328327
// Start React update, but don't finish
329328
if (gate(flags => flags.enableSyncDefaultUpdates)) {
330-
React.unstable_startTransition(() => {
329+
React.startTransition(() => {
331330
ReactNoop.render(<Parent observed={observableB} />);
332331
});
333332
} else {
@@ -362,7 +361,6 @@ describe('createSubscription', () => {
362361
]);
363362
});
364363

365-
// @gate experimental || !enableSyncDefaultUpdates
366364
it('should not drop values emitted between updates', () => {
367365
const log = [];
368366

@@ -421,7 +419,7 @@ describe('createSubscription', () => {
421419

422420
// Start React update, but don't finish
423421
if (gate(flags => flags.enableSyncDefaultUpdates)) {
424-
React.unstable_startTransition(() => {
422+
React.startTransition(() => {
425423
ReactNoop.render(<Parent observed={observableB} />);
426424
});
427425
} else {

packages/react-debug-tools/src/__tests__/ReactHooksInspectionIntegration-test.js

+38-39
Original file line numberDiff line numberDiff line change
@@ -366,10 +366,9 @@ describe('ReactHooksInspectionIntegration', () => {
366366
]);
367367
});
368368

369-
// @gate experimental
370369
it('should support composite useTransition hook', () => {
371370
function Foo(props) {
372-
React.unstable_useTransition();
371+
React.useTransition();
373372
const memoizedValue = React.useMemo(() => 'hello', []);
374373
return <div>{memoizedValue}</div>;
375374
}
@@ -394,10 +393,9 @@ describe('ReactHooksInspectionIntegration', () => {
394393
]);
395394
});
396395

397-
// @gate experimental
398396
it('should support composite useDeferredValue hook', () => {
399397
function Foo(props) {
400-
React.unstable_useDeferredValue('abc', {
398+
React.useDeferredValue('abc', {
401399
timeoutMs: 500,
402400
});
403401
const [state] = React.useState(() => 'hello', []);
@@ -424,7 +422,6 @@ describe('ReactHooksInspectionIntegration', () => {
424422
]);
425423
});
426424

427-
// @gate experimental
428425
it('should support composite useOpaqueIdentifier hook', () => {
429426
function Foo(props) {
430427
const id = React.unstable_useOpaqueIdentifier();
@@ -452,7 +449,6 @@ describe('ReactHooksInspectionIntegration', () => {
452449
});
453450
});
454451

455-
// @gate experimental
456452
it('should support composite useOpaqueIdentifier hook in concurrent mode', () => {
457453
function Foo(props) {
458454
const id = React.unstable_useOpaqueIdentifier();
@@ -846,37 +842,40 @@ describe('ReactHooksInspectionIntegration', () => {
846842
]);
847843
});
848844

849-
if (__EXPERIMENTAL__) {
850-
it('should support composite useMutableSource hook', () => {
851-
const mutableSource = React.unstable_createMutableSource({}, () => 1);
852-
function Foo(props) {
853-
React.unstable_useMutableSource(
854-
mutableSource,
855-
() => 'snapshot',
856-
() => {},
857-
);
858-
React.useMemo(() => 'memo', []);
859-
return <div />;
860-
}
861-
const renderer = ReactTestRenderer.create(<Foo />);
862-
const childFiber = renderer.root.findByType(Foo)._currentFiber();
863-
const tree = ReactDebugTools.inspectHooksOfFiber(childFiber);
864-
expect(tree).toEqual([
865-
{
866-
id: 0,
867-
isStateEditable: false,
868-
name: 'MutableSource',
869-
value: 'snapshot',
870-
subHooks: [],
871-
},
872-
{
873-
id: 1,
874-
isStateEditable: false,
875-
name: 'Memo',
876-
value: 'memo',
877-
subHooks: [],
878-
},
879-
]);
880-
});
881-
}
845+
it('should support composite useMutableSource hook', () => {
846+
const createMutableSource =
847+
React.createMutableSource || React.unstable_createMutableSource;
848+
const useMutableSource =
849+
React.useMutableSource || React.unstable_useMutableSource;
850+
851+
const mutableSource = createMutableSource({}, () => 1);
852+
function Foo(props) {
853+
useMutableSource(
854+
mutableSource,
855+
() => 'snapshot',
856+
() => {},
857+
);
858+
React.useMemo(() => 'memo', []);
859+
return <div />;
860+
}
861+
const renderer = ReactTestRenderer.create(<Foo />);
862+
const childFiber = renderer.root.findByType(Foo)._currentFiber();
863+
const tree = ReactDebugTools.inspectHooksOfFiber(childFiber);
864+
expect(tree).toEqual([
865+
{
866+
id: 0,
867+
isStateEditable: false,
868+
name: 'MutableSource',
869+
value: 'snapshot',
870+
subHooks: [],
871+
},
872+
{
873+
id: 1,
874+
isStateEditable: false,
875+
name: 'Memo',
876+
value: 'memo',
877+
subHooks: [],
878+
},
879+
]);
880+
});
882881
});

packages/react-devtools-core/src/standalone.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
// $FlowFixMe Flow does not yet know about flushSync()
1313
flushSync,
1414
// $FlowFixMe Flow does not yet know about createRoot()
15-
unstable_createRoot as createRoot,
15+
createRoot,
1616
} from 'react-dom';
1717
import Bridge from 'react-devtools-shared/src/bridge';
1818
import Store from 'react-devtools-shared/src/devtools/store';

packages/react-devtools-extensions/src/main.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* global chrome */
22

33
import {createElement} from 'react';
4-
import {unstable_createRoot as createRoot, flushSync} from 'react-dom';
4+
import {createRoot, flushSync} from 'react-dom';
55
import Bridge from 'react-devtools-shared/src/bridge';
66
import Store from 'react-devtools-shared/src/devtools/store';
77
import {getBrowserName, getBrowserTheme} from './utils';

packages/react-devtools-scheduling-profiler/src/hooks.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
*/
99

1010
import {
11+
// $FlowFixMe
1112
unstable_createMutableSource as createMutableSource,
12-
unstable_useMutableSource as useMutableSource,
1313
useLayoutEffect,
14+
// $FlowFixMe
15+
unstable_useMutableSource as useMutableSource,
1416
} from 'react';
1517

1618
import {

packages/react-devtools-scheduling-profiler/src/import-worker/__tests__/preprocessData-test.internal.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ describe(preprocessData, () => {
382382
});
383383
});
384384

385-
// @gate experimental && enableSchedulingProfiler
385+
// @gate enableSchedulingProfiler
386386
it('should process a sample createRoot render sequence', () => {
387387
function App() {
388388
const [didMount, setDidMount] = React.useState(false);

packages/react-devtools-scheduling-profiler/src/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'regenerator-runtime/runtime';
1111

1212
import * as React from 'react';
1313
// $FlowFixMe Flow does not yet know about createRoot()
14-
import {unstable_createRoot as createRoot} from 'react-dom';
14+
import {createRoot} from 'react-dom';
1515
import nullthrows from 'nullthrows';
1616
import App from './App';
1717

packages/react-devtools-shared/src/__tests__/profilingCommitTreeBuilder-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ describe('commit tree', () => {
149149

150150
it('should support Lazy components (createRoot)', async () => {
151151
const container = document.createElement('div');
152-
const root = ReactDOM.unstable_createRoot(container);
152+
const root = ReactDOM.createRoot(container);
153153

154154
utils.act(() => store.profilerStore.startProfiling());
155155
utils.act(() => root.render(<App renderChildren={true} />));
@@ -226,7 +226,7 @@ describe('commit tree', () => {
226226

227227
it('should support Lazy components that are unmounted before resolving (createRoot)', async () => {
228228
const container = document.createElement('div');
229-
const root = ReactDOM.unstable_createRoot(container);
229+
const root = ReactDOM.createRoot(container);
230230

231231
utils.act(() => store.profilerStore.startProfiling());
232232
utils.act(() => root.render(<App renderChildren={true} />));

packages/react-devtools-shared/src/__tests__/profilingHostRoot-test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ describe('profiling HostRoot', () => {
8989
utils.act(() => store.profilerStore.startProfiling());
9090
utils.act(() => {
9191
const container = document.createElement('div');
92-
const root = ReactDOM.unstable_createRoot(container);
92+
const root = ReactDOM.createRoot(container);
9393
root.render(<App />);
9494
});
9595
utils.act(() => store.profilerStore.stopProfiling());
@@ -122,7 +122,7 @@ describe('profiling HostRoot', () => {
122122
}
123123

124124
const container = document.createElement('div');
125-
const root = ReactDOM.unstable_createRoot(container);
125+
const root = ReactDOM.createRoot(container);
126126

127127
utils.act(() => store.profilerStore.startProfiling());
128128
utils.act(() => root.render(<App />));

packages/react-devtools-shared/src/__tests__/store-test.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -356,18 +356,18 @@ describe('Store', () => {
356356
};
357357
const Wrapper = ({shouldSuspense}) => (
358358
<React.Fragment>
359-
<React.unstable_SuspenseList revealOrder="forwards" tail="collapsed">
359+
<React.SuspenseList revealOrder="forwards" tail="collapsed">
360360
<Component key="A" />
361361
<React.Suspense fallback={<Loading />}>
362362
{shouldSuspense ? <SuspendingComponent /> : <Component key="B" />}
363363
</React.Suspense>
364364
<Component key="C" />
365-
</React.unstable_SuspenseList>
365+
</React.SuspenseList>
366366
</React.Fragment>
367367
);
368368

369369
const container = document.createElement('div');
370-
const root = ReactDOM.unstable_createRoot(container);
370+
const root = ReactDOM.createRoot(container);
371371
act(() => {
372372
root.render(<Wrapper shouldSuspense={true} />);
373373
});
@@ -984,7 +984,7 @@ describe('Store', () => {
984984

985985
it('should support Lazy components in (createRoot)', async () => {
986986
const container = document.createElement('div');
987-
const root = ReactDOM.unstable_createRoot(container);
987+
const root = ReactDOM.createRoot(container);
988988

989989
// Render once to start fetching the lazy component
990990
act(() => root.render(<App renderChildren={true} />));
@@ -1020,7 +1020,7 @@ describe('Store', () => {
10201020

10211021
it('should support Lazy components that are unmounted before they finish loading in (createRoot)', async () => {
10221022
const container = document.createElement('div');
1023-
const root = ReactDOM.unstable_createRoot(container);
1023+
const root = ReactDOM.createRoot(container);
10241024

10251025
// Render once to start fetching the lazy component
10261026
act(() => root.render(<App renderChildren={true} />));

0 commit comments

Comments
 (0)