From 0894b2cbc8ce0eba23425da17a93033aac6aa0dc Mon Sep 17 00:00:00 2001 From: Sebastian Silbermann Date: Sun, 28 Jan 2024 14:08:01 +0100 Subject: [PATCH] Convert ReactMultiChildText to createRoot --- .../src/__tests__/ReactMultiChildText-test.js | 92 +++++++++++-------- 1 file changed, 56 insertions(+), 36 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactMultiChildText-test.js b/packages/react-dom/src/__tests__/ReactMultiChildText-test.js index 529b61604fbb5..450d0383eb0fc 100644 --- a/packages/react-dom/src/__tests__/ReactMultiChildText-test.js +++ b/packages/react-dom/src/__tests__/ReactMultiChildText-test.js @@ -11,7 +11,6 @@ const React = require('react'); const ReactDOMClient = require('react-dom/client'); -const ReactTestUtils = require('react-dom/test-utils'); const act = require('internal-test-utils').act; // Helpers @@ -174,46 +173,67 @@ describe('ReactMultiChildText', () => { ]); }); - it('should throw if rendering both HTML and children', () => { - expect(function () { - ReactTestUtils.renderIntoDocument( -
ghjkl
, - ); - }).toThrow(); + it('should throw if rendering both HTML and children', async () => { + const container = document.createElement('div'); + const root = ReactDOMClient.createRoot(container); + await expect( + act(() => { + root.render( +
ghjkl
, + ); + }), + ).rejects.toThrow(); }); - it('should render between nested components and inline children', () => { - ReactTestUtils.renderIntoDocument( -
-

- - -

-
, - ); - - expect(function () { - ReactTestUtils.renderIntoDocument( -
-

A

-
, - ); - }).not.toThrow(); - - expect(function () { - ReactTestUtils.renderIntoDocument( -
-

{['A']}

-
, - ); - }).not.toThrow(); + it('should render between nested components and inline children', async () => { + let container = document.createElement('div'); + let root = ReactDOMClient.createRoot(container); - expect(function () { - ReactTestUtils.renderIntoDocument( + await act(() => { + root.render(
-

{['A', 'B']}

+

+ + +

, ); - }).not.toThrow(); + }); + + container = document.createElement('div'); + root = ReactDOMClient.createRoot(container); + await expect( + act(() => { + root.render( +
+

A

+
, + ); + }), + ).resolves.not.toThrow(); + + container = document.createElement('div'); + root = ReactDOMClient.createRoot(container); + await expect( + act(() => { + root.render( +
+

{['A']}

+
, + ); + }), + ).resolves.not.toThrow(); + + container = document.createElement('div'); + root = ReactDOMClient.createRoot(container); + await expect( + act(() => { + root.render( +
+

{['A', 'B']}

+
, + ); + }), + ).resolves.not.toThrow(); }); });