Skip to content

Commit

Permalink
chore: use versioned render in storeOwners test (#28215)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxyq authored Feb 5, 2024
1 parent 7e77e29 commit 4f82bf4
Showing 1 changed file with 11 additions and 33 deletions.
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

0 comments on commit 4f82bf4

Please sign in to comment.