Skip to content

Commit 6d2a1d0

Browse files
authored
Convert ReactMultiChildText to createRoot (#28140)
1 parent 313e4d4 commit 6d2a1d0

File tree

1 file changed

+56
-36
lines changed

1 file changed

+56
-36
lines changed

packages/react-dom/src/__tests__/ReactMultiChildText-test.js

+56-36
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
const React = require('react');
1313
const ReactDOMClient = require('react-dom/client');
14-
const ReactTestUtils = require('react-dom/test-utils');
1514
const act = require('internal-test-utils').act;
1615

1716
// Helpers
@@ -174,46 +173,67 @@ describe('ReactMultiChildText', () => {
174173
]);
175174
});
176175

177-
it('should throw if rendering both HTML and children', () => {
178-
expect(function () {
179-
ReactTestUtils.renderIntoDocument(
180-
<div dangerouslySetInnerHTML={{__html: 'abcdef'}}>ghjkl</div>,
181-
);
182-
}).toThrow();
176+
it('should throw if rendering both HTML and children', async () => {
177+
const container = document.createElement('div');
178+
const root = ReactDOMClient.createRoot(container);
179+
await expect(
180+
act(() => {
181+
root.render(
182+
<div dangerouslySetInnerHTML={{__html: 'abcdef'}}>ghjkl</div>,
183+
);
184+
}),
185+
).rejects.toThrow();
183186
});
184187

185-
it('should render between nested components and inline children', () => {
186-
ReactTestUtils.renderIntoDocument(
187-
<div>
188-
<h1>
189-
<span />
190-
<span />
191-
</h1>
192-
</div>,
193-
);
194-
195-
expect(function () {
196-
ReactTestUtils.renderIntoDocument(
197-
<div>
198-
<h1>A</h1>
199-
</div>,
200-
);
201-
}).not.toThrow();
202-
203-
expect(function () {
204-
ReactTestUtils.renderIntoDocument(
205-
<div>
206-
<h1>{['A']}</h1>
207-
</div>,
208-
);
209-
}).not.toThrow();
188+
it('should render between nested components and inline children', async () => {
189+
let container = document.createElement('div');
190+
let root = ReactDOMClient.createRoot(container);
210191

211-
expect(function () {
212-
ReactTestUtils.renderIntoDocument(
192+
await act(() => {
193+
root.render(
213194
<div>
214-
<h1>{['A', 'B']}</h1>
195+
<h1>
196+
<span />
197+
<span />
198+
</h1>
215199
</div>,
216200
);
217-
}).not.toThrow();
201+
});
202+
203+
container = document.createElement('div');
204+
root = ReactDOMClient.createRoot(container);
205+
await expect(
206+
act(() => {
207+
root.render(
208+
<div>
209+
<h1>A</h1>
210+
</div>,
211+
);
212+
}),
213+
).resolves.not.toThrow();
214+
215+
container = document.createElement('div');
216+
root = ReactDOMClient.createRoot(container);
217+
await expect(
218+
act(() => {
219+
root.render(
220+
<div>
221+
<h1>{['A']}</h1>
222+
</div>,
223+
);
224+
}),
225+
).resolves.not.toThrow();
226+
227+
container = document.createElement('div');
228+
root = ReactDOMClient.createRoot(container);
229+
await expect(
230+
act(() => {
231+
root.render(
232+
<div>
233+
<h1>{['A', 'B']}</h1>
234+
</div>,
235+
);
236+
}),
237+
).resolves.not.toThrow();
218238
});
219239
});

0 commit comments

Comments
 (0)