Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use versioned render in storeOwners test #28215

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 11 additions & 33 deletions packages/react-devtools-shared/src/__tests__/storeOwners-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
*/

const {printOwnersList} = require('../devtools/utils');
const {getVersionedRenderImplementation} = require('./utils');

describe('Store owners list', () => {
let React;
let act;
let legacyRender;
let store;

beforeEach(() => {
Expand All @@ -23,9 +23,10 @@ describe('Store owners list', () => {

const utils = require('./utils');
act = utils.act;
legacyRender = utils.legacyRender;
});

const {render} = getVersionedRenderImplementation();

function getFormattedOwnersList(elementID) {
const ownersList = store.getOwnersListForElement(elementID);
return printOwnersList(ownersList);
Expand All @@ -43,7 +44,7 @@ describe('Store owners list', () => {
const Leaf = () => <div>Leaf</div>;
const Intermediate = ({children}) => <Wrapper>{children}</Wrapper>;

act(() => legacyRender(<Root />, document.createElement('div')));
act(() => render(<Root />));
expect(store).toMatchInlineSnapshot(`
[root]
▾ <Root>
Expand Down Expand Up @@ -80,7 +81,7 @@ describe('Store owners list', () => {
<Wrapper key="wrapper">{children}</Wrapper>,
];

act(() => legacyRender(<Root />, document.createElement('div')));
act(() => render(<Root />));
expect(store).toMatchInlineSnapshot(`
[root]
▾ <Root>
Expand Down Expand Up @@ -122,14 +123,7 @@ describe('Store owners list', () => {
const Leaf = () => <div>Leaf</div>;
const Intermediate = ({children}) => <Wrapper>{children}</Wrapper>;

const container = document.createElement('div');

act(() =>
legacyRender(
<Root includeDirect={false} includeIndirect={true} />,
container,
),
);
act(() => render(<Root includeDirect={false} includeIndirect={true} />));

const rootID = store.getElementIDAtIndex(0);
expect(store).toMatchInlineSnapshot(`
Expand All @@ -145,12 +139,7 @@ describe('Store owners list', () => {
<Leaf>"
`);

act(() =>
legacyRender(
<Root includeDirect={true} includeIndirect={true} />,
container,
),
);
act(() => render(<Root includeDirect={true} includeIndirect={true} />));
expect(store).toMatchInlineSnapshot(`
[root]
▾ <Root>
Expand All @@ -166,12 +155,7 @@ describe('Store owners list', () => {
<Leaf>"
`);

act(() =>
legacyRender(
<Root includeDirect={true} includeIndirect={false} />,
container,
),
);
act(() => render(<Root includeDirect={true} includeIndirect={false} />));
expect(store).toMatchInlineSnapshot(`
[root]
▾ <Root>
Expand All @@ -182,12 +166,7 @@ describe('Store owners list', () => {
<Leaf>"
`);

act(() =>
legacyRender(
<Root includeDirect={false} includeIndirect={false} />,
container,
),
);
act(() => render(<Root includeDirect={false} includeIndirect={false} />));
expect(store).toMatchInlineSnapshot(`
[root]
<Root>
Expand All @@ -204,8 +183,7 @@ describe('Store owners list', () => {
: [<Leaf key="C" />, <Leaf key="B" />, <Leaf key="A" />];
const Leaf = () => <div>Leaf</div>;

const container = document.createElement('div');
act(() => legacyRender(<Root ascending={true} />, container));
act(() => render(<Root ascending={true} />));

const rootID = store.getElementIDAtIndex(0);
expect(store).toMatchInlineSnapshot(`
Expand All @@ -222,7 +200,7 @@ describe('Store owners list', () => {
<Leaf key="C">"
`);

act(() => legacyRender(<Root ascending={false} />, container));
act(() => render(<Root ascending={false} />));
expect(store).toMatchInlineSnapshot(`
[root]
▾ <Root>
Expand Down