Skip to content

Commit

Permalink
Add ReactDOMClient to ServerIntegrationElements
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Jan 28, 2024
1 parent 233b65d commit 9fed422
Showing 1 changed file with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,21 @@ const TEXT_NODE_TYPE = 3;

let React;
let ReactDOM;
let ReactDOMClient;
let ReactDOMServer;
let ReactTestUtils;

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,
};
Expand Down Expand Up @@ -136,7 +138,13 @@ 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(<nonstandard />, document.createElement('div'));
ReactDOM.flushSync(() => {
const root = ReactDOMClient.createRoot(
document.createElement('div'),
);

root.render(<nonstandard />);
});
}).toErrorDev('The tag <nonstandard> is unrecognized in this browser.');

const e = await render(<nonstandard>Text</nonstandard>);
Expand Down Expand Up @@ -842,6 +850,8 @@ describe('ReactDOMServerIntegration', () => {
expect(e.childNodes.length).toBe(1);
// Client rendering (or hydration) uses JS value with CR.
// Null character stays.

//TODO: fixme - This is broken
expectNode(
e.childNodes[0],
TEXT_NODE_TYPE,
Expand Down Expand Up @@ -871,6 +881,8 @@ describe('ReactDOMServerIntegration', () => {
// We have three nodes because there is a comment between them.
expect(e.childNodes.length).toBe(3);
// Hydration uses JS value with CR and null character.

//TODO: fixme - This is broken
expectNode(e.childNodes[0], TEXT_NODE_TYPE, 'foo\rbar');
expectNode(e.childNodes[2], TEXT_NODE_TYPE, '\r\nbaz\nqux\u0000');
} else {
Expand Down

0 comments on commit 9fed422

Please sign in to comment.