| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | * |
| 7 | * @emails react-core |
| 8 | */ |
| 9 | |
| 10 | 'use strict'; |
| 11 | |
| 12 | const React = require('react'); |
| 13 | const ReactDOMClient = require('react-dom/client'); |
| 14 | |
| 15 | const act = require('internal-test-utils').act; |
| 16 | |
| 17 | describe('dangerouslySetInnerHTML', () => { |
| 18 | describe('when the node has innerHTML property', () => { |
| 19 | it('sets innerHTML on it', async () => { |
| 20 | const container = document.createElement('div'); |
| 21 | const root = ReactDOMClient.createRoot(container); |
| 22 | await act(() => { |
| 23 | root.render( |
| 24 | <div dangerouslySetInnerHTML={{__html: '<h1>Hello</h1>'}} />, |
| 25 | ); |
| 26 | }); |
| 27 | expect(container.firstChild.innerHTML).toBe('<h1>Hello</h1>'); |
| 28 | }); |
| 29 | }); |
| 30 | }); |