| 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 | * @jest-environment ./scripts/jest/ReactDOMServerIntegrationEnvironment |
| 8 | */ |
| 9 | |
| 10 | 'use strict'; |
| 11 | |
| 12 | const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegrationTestUtils'); |
| 13 | |
| 14 | let React; |
| 15 | let ReactDOMClient; |
| 16 | let ReactDOMServer; |
| 17 | |
| 18 | function initModules() { |
| 19 | // Reset warning cache. |
| 20 | jest.resetModules(); |
| 21 | React = require('react'); |
| 22 | ReactDOMClient = require('react-dom/client'); |
| 23 | ReactDOMServer = require('react-dom/server'); |
| 24 | |
| 25 | // Make them available to the helpers. |
| 26 | return { |
| 27 | ReactDOMClient, |
| 28 | ReactDOMServer, |
| 29 | }; |
| 30 | } |
| 31 | |
| 32 | const {resetModules, itRenders} = ReactDOMServerIntegrationUtils(initModules); |
| 33 | |
| 34 | describe('ReactDOMServerIntegrationObject', () => { |
| 35 | beforeEach(() => { |
| 36 | resetModules(); |
| 37 | }); |
| 38 | |
| 39 | itRenders('an object with children', async render => { |
| 40 | const e = await render( |
| 41 | <object type="video/mp4" data="/example.webm" width={600} height={400}> |
| 42 | <div>preview</div> |
| 43 | </object>, |
| 44 | ); |
| 45 | |
| 46 | expect(e.outerHTML).toBe( |
| 47 | '<object type="video/mp4" data="/example.webm" width="600" height="400"><div>preview</div></object>', |
| 48 | ); |
| 49 | }); |
| 50 | |
| 51 | itRenders('an object with empty data', async render => { |
| 52 | const e = await render(<object data="" />, 1); |
| 53 | expect(e.outerHTML).toBe('<object></object>'); |
| 54 | }); |
| 55 | }); |