|
11 | 11 |
|
12 | 12 | const React = require('react');
|
13 | 13 | const ReactDOMClient = require('react-dom/client');
|
14 |
| -const ReactTestUtils = require('react-dom/test-utils'); |
15 | 14 | const act = require('internal-test-utils').act;
|
16 | 15 |
|
17 | 16 | // Helpers
|
@@ -174,46 +173,67 @@ describe('ReactMultiChildText', () => {
|
174 | 173 | ]);
|
175 | 174 | });
|
176 | 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(); |
183 | 186 | });
|
184 | 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); |
210 | 191 |
|
211 |
| - expect(function () { |
212 |
| - ReactTestUtils.renderIntoDocument( |
| 192 | + await act(() => { |
| 193 | + root.render( |
213 | 194 | <div>
|
214 |
| - <h1>{['A', 'B']}</h1> |
| 195 | + <h1> |
| 196 | + <span /> |
| 197 | + <span /> |
| 198 | + </h1> |
215 | 199 | </div>,
|
216 | 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(); |
218 | 238 | });
|
219 | 239 | });
|
0 commit comments