Skip to content

Commit

Permalink
Remove dupe test
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack Pope committed Mar 12, 2024
1 parent c9569f7 commit 4428e6e
Showing 1 changed file with 0 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1179,168 +1179,6 @@ describe('ReactHooksInspectionIntegration', () => {
`);
});

it('should update isPending returned from useTransition', async () => {
const IndefiniteSuspender = React.lazy(() => new Promise(() => {}));
let startTransition;
function Foo(props) {
const [show, setShow] = React.useState(false);
const [isPending, _startTransition] = React.useTransition();
React.useMemo(() => 'hello', []);
React.useMemo(() => 'not used', []);

// Otherwise we capture the version from the react-debug-tools dispatcher.
if (startTransition === undefined) {
startTransition = () => {
_startTransition(() => {
setShow(true);
});
};
}

return (
<React.Suspense fallback="Loading">
{isPending ? 'Pending' : null}
{show ? <IndefiniteSuspender /> : null}
</React.Suspense>
);
}
const renderer = await act(() => {
return ReactTestRenderer.create(<Foo />, {unstable_isConcurrent: true});
});
expect(renderer).toMatchRenderedOutput(null);
let childFiber = renderer.root.findByType(Foo)._currentFiber();
let tree = ReactDebugTools.inspectHooksOfFiber(childFiber);
expect(normalizeSourceLoc(tree)).toMatchInlineSnapshot(`
[
{
"debugInfo": null,
"hookSource": {
"columnNumber": 0,
"fileName": "**",
"functionName": "Foo",
"lineNumber": 0,
},
"id": 0,
"isStateEditable": true,
"name": "State",
"subHooks": [],
"value": false,
},
{
"debugInfo": null,
"hookSource": {
"columnNumber": 0,
"fileName": "**",
"functionName": "Foo",
"lineNumber": 0,
},
"id": 1,
"isStateEditable": false,
"name": "Transition",
"subHooks": [],
"value": false,
},
{
"debugInfo": null,
"hookSource": {
"columnNumber": 0,
"fileName": "**",
"functionName": "Foo",
"lineNumber": 0,
},
"id": 2,
"isStateEditable": false,
"name": "Memo",
"subHooks": [],
"value": "hello",
},
{
"debugInfo": null,
"hookSource": {
"columnNumber": 0,
"fileName": "**",
"functionName": "Foo",
"lineNumber": 0,
},
"id": 3,
"isStateEditable": false,
"name": "Memo",
"subHooks": [],
"value": "not used",
},
]
`);

await act(() => {
startTransition();
});

expect(renderer).toMatchRenderedOutput('Pending');

childFiber = renderer.root.findByType(Foo)._currentFiber();
tree = ReactDebugTools.inspectHooksOfFiber(childFiber);
expect(normalizeSourceLoc(tree)).toMatchInlineSnapshot(`
[
{
"debugInfo": null,
"hookSource": {
"columnNumber": 0,
"fileName": "**",
"functionName": "Foo",
"lineNumber": 0,
},
"id": 0,
"isStateEditable": true,
"name": "State",
"subHooks": [],
"value": false,
},
{
"debugInfo": null,
"hookSource": {
"columnNumber": 0,
"fileName": "**",
"functionName": "Foo",
"lineNumber": 0,
},
"id": 1,
"isStateEditable": false,
"name": "Transition",
"subHooks": [],
"value": true,
},
{
"debugInfo": null,
"hookSource": {
"columnNumber": 0,
"fileName": "**",
"functionName": "Foo",
"lineNumber": 0,
},
"id": 2,
"isStateEditable": false,
"name": "Memo",
"subHooks": [],
"value": "hello",
},
{
"debugInfo": null,
"hookSource": {
"columnNumber": 0,
"fileName": "**",
"functionName": "Foo",
"lineNumber": 0,
},
"id": 3,
"isStateEditable": false,
"name": "Memo",
"subHooks": [],
"value": "not used",
},
]
`);
});

it('should support useDeferredValue hook', async () => {
function Foo(props) {
React.useDeferredValue('abc');
Expand Down

0 comments on commit 4428e6e

Please sign in to comment.