Skip to content

Commit

Permalink
Current behavior for rootType
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Sep 20, 2021
1 parent 8209de2 commit ea5c55a
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ describe('InspectedElement', () => {
"a": 1,
"b": "abc",
},
"rootType": "createLegacyRoot()",
"state": null,
}
`);
Expand Down Expand Up @@ -1584,6 +1585,7 @@ describe('InspectedElement', () => {
"a": 1,
"b": "abc",
},
"rootType": "createLegacyRoot()",
"state": null,
}
`);
Expand Down Expand Up @@ -1912,6 +1914,7 @@ describe('InspectedElement', () => {
"id": 2,
"owners": null,
"props": Object {},
"rootType": "createLegacyRoot()",
"state": null,
}
`);
Expand Down Expand Up @@ -1944,11 +1947,71 @@ describe('InspectedElement', () => {
"id": 2,
"owners": null,
"props": Object {},
"rootType": "createLegacyRoot()",
"state": null,
}
`);
});

it('should display the root type for ReactDOM.hydrate', async () => {
const Example = () => <div />;

await utils.actAsync(() => {
const container = document.createElement('div');
container.innerHTML = '<div></div>';
withErrorsOrWarningsIgnored(
['ReactDOM.hydrate is no longer supported in React 18'],
() => {
ReactDOM.hydrate(<Example />, container);
},
);
}, false);

const inspectedElement = await inspectElementAtIndex(0);
expect(inspectedElement.rootType).toMatchInlineSnapshot(
`"createLegacyRoot()"`,
);
});

it('should display the root type for ReactDOM.render', async () => {
const Example = () => <div />;

await utils.actAsync(() => {
const container = document.createElement('div');
legacyRender(<Example />, container);
}, false);

const inspectedElement = await inspectElementAtIndex(0);
expect(inspectedElement.rootType).toMatchInlineSnapshot(
`"createLegacyRoot()"`,
);
});

it('should display the root type for ReactDOM.hydrateRoot', async () => {
const Example = () => <div />;

await utils.actAsync(() => {
const container = document.createElement('div');
container.innerHTML = '<div></div>';
ReactDOM.hydrateRoot(container).render(<Example />);
}, false);

const inspectedElement = await inspectElementAtIndex(0);
expect(inspectedElement.rootType).toMatchInlineSnapshot(`"createRoot()"`);
});

it('should display the root type for ReactDOM.createRoot', async () => {
const Example = () => <div />;

await utils.actAsync(() => {
const container = document.createElement('div');
ReactDOM.createRoot(container).render(<Example />);
}, false);

const inspectedElement = await inspectElementAtIndex(0);
expect(inspectedElement.rootType).toMatchInlineSnapshot(`"createRoot()"`);
});

describe('$r', () => {
it('should support function components', async () => {
const Example = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function print(inspectedElement, serialize, indent) {
id: inspectedElement.id,
owners: inspectedElement.owners,
props: inspectedElement.props,
rootType: inspectedElement.rootType,
state: inspectedElement.state,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ describe('InspectedElementContext', () => {
"a": 1,
"b": "abc",
},
"rootType": null,
"state": null,
}
`);
Expand Down Expand Up @@ -133,6 +134,7 @@ describe('InspectedElementContext', () => {
"value_null": null,
"value_undefined": undefined,
},
"rootType": null,
"state": null,
}
`);
Expand Down Expand Up @@ -408,6 +410,7 @@ describe('InspectedElementContext', () => {
"preview_long": Generator,
},
},
"rootType": null,
"state": null,
}
`);
Expand Down Expand Up @@ -461,6 +464,7 @@ describe('InspectedElementContext', () => {
"number": 42,
},
},
"rootType": null,
"state": null,
}
`);
Expand Down Expand Up @@ -552,6 +556,7 @@ describe('InspectedElementContext', () => {
"enumerableStringBase": 1,
},
},
"rootType": null,
"state": null,
}
`);
Expand Down

0 comments on commit ea5c55a

Please sign in to comment.