@samitouri / QOS-React-2 / commits / 6d2a1d0334

Convert ReactMultiChildText to createRoot (#28140)

Sebastian Silbermann committed Jan 29, 2024 at 09:11 UTC 6d2a1d0334581c1cdb269863f6a73d152a671c49
1 file changed +56 -36
packages/react-dom/src/__tests__/ReactMultiChildText-test.js
+56 -36
@@ -11,7 +11,6 @@
11
12 const React = require('react');
13 const ReactDOMClient = require('react-dom/client');
14 -const ReactTestUtils = require('react-dom/test-utils');
14 const act = require('internal-test-utils').act;
15
16 // Helpers
@@ -174,46 +173,67 @@ describe('ReactMultiChildText', () => {
173 ]);
174 });
175
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();
186 });
187
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);
191
211 - expect(function () {
212 - ReactTestUtils.renderIntoDocument(
192 + await act(() => {
193 + root.render(
194 <div>
214 - <h1>{['A', 'B']}</h1>
195 + <h1>
196 + <span />
197 + <span />
198 + </h1>
199 </div>,
200 );
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();
238 });
239 });