From 01410a08400be07b1eb10edc02852a8fe347efbb Mon Sep 17 00:00:00 2001 From: Ricky Hanlon Date: Sat, 27 Jan 2024 17:52:18 -0500 Subject: [PATCH] Add ReactDOMClient to ServerIntegration tests (minor fixes) --- .../ReactDOMServerIntegrationAttributes-test.js | 11 +++++++++-- .../ReactDOMServerIntegrationUntrustedURL-test.js | 7 ++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationAttributes-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationAttributes-test.js index 36c3c0cb94840..bda021b5e06a7 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationAttributes-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationAttributes-test.js @@ -15,6 +15,7 @@ const ReactFeatureFlags = require('shared/ReactFeatureFlags'); let React; let ReactDOM; +let ReactDOMClient; let ReactTestUtils; let ReactDOMServer; @@ -23,12 +24,13 @@ function initModules() { jest.resetModules(); React = require('react'); ReactDOM = require('react-dom'); + ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); ReactTestUtils = require('react-dom/test-utils'); // Make them available to the helpers. return { - ReactDOM, + ReactDOMClient, ReactDOMServer, ReactTestUtils, }; @@ -638,7 +640,12 @@ describe('ReactDOMServerIntegration', () => { // DOM nodes on the client side. We force it to fire early // so that it gets deduplicated later, and doesn't fail the test. expect(() => { - ReactDOM.render(, document.createElement('div')); + ReactDOM.flushSync(() => { + const root = ReactDOMClient.createRoot( + document.createElement('div'), + ); + root.render(); + }); }).toErrorDev('The tag is unrecognized in this browser.'); const e = await render(); diff --git a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUntrustedURL-test.js b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUntrustedURL-test.js index 121ffe93ad25a..55336a2cb5636 100644 --- a/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUntrustedURL-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMServerIntegrationUntrustedURL-test.js @@ -15,7 +15,6 @@ const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegrationTestUtils'); let React; -let ReactDOM; let ReactDOMClient; let ReactDOMServer; let ReactTestUtils; @@ -35,7 +34,6 @@ describe('ReactDOMServerIntegration - Untrusted URLs', () => { function initModules() { jest.resetModules(); React = require('react'); - ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); ReactTestUtils = require('react-dom/test-utils'); @@ -43,7 +41,7 @@ describe('ReactDOMServerIntegration - Untrusted URLs', () => { // Make them available to the helpers. return { - ReactDOM, + ReactDOMClient, ReactDOMServer, ReactTestUtils, }; @@ -204,7 +202,6 @@ describe('ReactDOMServerIntegration - Untrusted URLs - disableJavaScriptURLs', ( ReactFeatureFlags.disableJavaScriptURLs = true; React = require('react'); - ReactDOM = require('react-dom'); ReactDOMClient = require('react-dom/client'); ReactDOMServer = require('react-dom/server'); ReactTestUtils = require('react-dom/test-utils'); @@ -212,7 +209,7 @@ describe('ReactDOMServerIntegration - Untrusted URLs - disableJavaScriptURLs', ( // Make them available to the helpers. return { - ReactDOM, + ReactDOMClient, ReactDOMServer, ReactTestUtils, };