chore: use versioned render in storeOwners test (#28215)
Ruslan Lesiutin committed
Feb 5, 2024 at 17:15 UTC
4f82bf4f59a91e81191f39fa328a3d26aba6371a
1 file changed
+11
-33
packages/react-devtools-shared/src/__tests__/storeOwners-test.js
+11
-33
@@ -8,11 +8,11 @@
8
*/
9
10
const {printOwnersList} = require('../devtools/utils');
11
+const {getVersionedRenderImplementation} = require('./utils');
12
13
describe('Store owners list', () => {
14
let React;
15
let act;
15
- let legacyRender;
16
let store;
17
18
beforeEach(() => {
@@ -23,9 +23,10 @@ describe('Store owners list', () => {
23
24
const utils = require('./utils');
25
act = utils.act;
26
- legacyRender = utils.legacyRender;
26
});
27
28
+ const {render} = getVersionedRenderImplementation();
29
+
30
function getFormattedOwnersList(elementID) {
31
const ownersList = store.getOwnersListForElement(elementID);
32
return printOwnersList(ownersList);
@@ -43,7 +44,7 @@ describe('Store owners list', () => {
44
const Leaf = () => <div>Leaf</div>;
45
const Intermediate = ({children}) => <Wrapper>{children}</Wrapper>;
46
46
- act(() => legacyRender(<Root />, document.createElement('div')));
47
+ act(() => render(<Root />));
48
expect(store).toMatchInlineSnapshot(`
49
[root]
50
▾ <Root>
@@ -80,7 +81,7 @@ describe('Store owners list', () => {
81
<Wrapper key="wrapper">{children}</Wrapper>,
82
];
83
83
- act(() => legacyRender(<Root />, document.createElement('div')));
84
+ act(() => render(<Root />));
85
expect(store).toMatchInlineSnapshot(`
86
[root]
87
▾ <Root>
@@ -122,14 +123,7 @@ describe('Store owners list', () => {
123
const Leaf = () => <div>Leaf</div>;
124
const Intermediate = ({children}) => <Wrapper>{children}</Wrapper>;
125
125
- const container = document.createElement('div');
126
-
127
- act(() =>
128
- legacyRender(
129
- <Root includeDirect={false} includeIndirect={true} />,
130
- container,
131
- ),
132
- );
126
+ act(() => render(<Root includeDirect={false} includeIndirect={true} />));
127
128
const rootID = store.getElementIDAtIndex(0);
129
expect(store).toMatchInlineSnapshot(`
@@ -145,12 +139,7 @@ describe('Store owners list', () => {
139
<Leaf>"
140
`);
141
148
- act(() =>
149
- legacyRender(
150
- <Root includeDirect={true} includeIndirect={true} />,
151
- container,
152
- ),
153
- );
142
+ act(() => render(<Root includeDirect={true} includeIndirect={true} />));
143
expect(store).toMatchInlineSnapshot(`
144
[root]
145
▾ <Root>
@@ -166,12 +155,7 @@ describe('Store owners list', () => {
155
<Leaf>"
156
`);
157
169
- act(() =>
170
- legacyRender(
171
- <Root includeDirect={true} includeIndirect={false} />,
172
- container,
173
- ),
174
- );
158
+ act(() => render(<Root includeDirect={true} includeIndirect={false} />));
159
expect(store).toMatchInlineSnapshot(`
160
[root]
161
▾ <Root>
@@ -182,12 +166,7 @@ describe('Store owners list', () => {
166
<Leaf>"
167
`);
168
185
- act(() =>
186
- legacyRender(
187
- <Root includeDirect={false} includeIndirect={false} />,
188
- container,
189
- ),
190
- );
169
+ act(() => render(<Root includeDirect={false} includeIndirect={false} />));
170
expect(store).toMatchInlineSnapshot(`
171
[root]
172
<Root>
@@ -204,8 +183,7 @@ describe('Store owners list', () => {
183
: [<Leaf key="C" />, <Leaf key="B" />, <Leaf key="A" />];
184
const Leaf = () => <div>Leaf</div>;
185
207
- const container = document.createElement('div');
208
- act(() => legacyRender(<Root ascending={true} />, container));
186
+ act(() => render(<Root ascending={true} />));
187
188
const rootID = store.getElementIDAtIndex(0);
189
expect(store).toMatchInlineSnapshot(`
@@ -222,7 +200,7 @@ describe('Store owners list', () => {
200
<Leaf key="C">"
201
`);
202
225
- act(() => legacyRender(<Root ascending={false} />, container));
203
+ act(() => render(<Root ascending={false} />));
204
expect(store).toMatchInlineSnapshot(`
205
[root]
206
▾ <Root>