Skip to content

Commit 45ad1f7

Browse files
rickhanloniiAndyPengc12
authored andcommitted
Add ReactDOMClient to ServerIntegrationReconnecting (facebook#28136)
## Overview Branched off facebook#28130 ## Why In facebook#24276 we changed the new root behavior to error when a client-render is forced for certain cases, so these now expect a mismatch even though they're using `suppressHydrationWarning`.
1 parent 2ba47ff commit 45ad1f7

File tree

1 file changed

+98
-28
lines changed

1 file changed

+98
-28
lines changed

packages/react-dom/src/__tests__/ReactDOMServerIntegrationReconnecting-test.js

Lines changed: 98 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,30 @@ const ReactDOMServerIntegrationUtils = require('./utils/ReactDOMServerIntegratio
1313

1414
let React;
1515
let ReactDOM;
16+
let ReactDOMClient;
1617
let ReactDOMServer;
1718
let ReactTestUtils;
1819

19-
function initModules() {
20-
// Reset warning cache.
21-
jest.resetModules();
22-
23-
React = require('react');
24-
ReactDOM = require('react-dom');
25-
ReactDOMServer = require('react-dom/server');
26-
ReactTestUtils = require('react-dom/test-utils');
27-
28-
// Make them available to the helpers.
29-
return {
30-
ReactDOM,
31-
ReactDOMServer,
32-
ReactTestUtils,
33-
};
34-
}
35-
36-
const {resetModules, expectMarkupMismatch, expectMarkupMatch} =
37-
ReactDOMServerIntegrationUtils(initModules);
38-
3920
describe('ReactDOMServerIntegration', () => {
21+
function initModules() {
22+
// Reset warning cache.
23+
jest.resetModules();
24+
25+
React = require('react');
26+
ReactDOMClient = require('react-dom/client');
27+
ReactDOMServer = require('react-dom/server');
28+
ReactTestUtils = require('react-dom/test-utils');
29+
30+
// Make them available to the helpers.
31+
return {
32+
ReactDOMClient,
33+
ReactDOMServer,
34+
ReactTestUtils,
35+
};
36+
}
37+
38+
const {resetModules, expectMarkupMismatch, expectMarkupMatch} =
39+
ReactDOMServerIntegrationUtils(initModules);
4040
beforeEach(() => {
4141
resetModules();
4242
});
@@ -123,8 +123,8 @@ describe('ReactDOMServerIntegration', () => {
123123
it('should error reconnecting different attribute values', () =>
124124
expectMarkupMismatch(<div id="foo" />, <div id="bar" />));
125125

126-
it('can explicitly ignore errors reconnecting different element types of children', () =>
127-
expectMarkupMatch(
126+
it('should error reconnecting different element types of children', () =>
127+
expectMarkupMismatch(
128128
<div>
129129
<div />
130130
</div>,
@@ -354,8 +354,8 @@ describe('ReactDOMServerIntegration', () => {
354354
<div>{''}</div>,
355355
));
356356

357-
it('can explicitly ignore reconnecting more children', () =>
358-
expectMarkupMatch(
357+
it('can not ignore reconnecting more children', () =>
358+
expectMarkupMismatch(
359359
<div>
360360
<div />
361361
</div>,
@@ -365,8 +365,8 @@ describe('ReactDOMServerIntegration', () => {
365365
</div>,
366366
));
367367

368-
it('can explicitly ignore reconnecting fewer children', () =>
369-
expectMarkupMatch(
368+
it('can not ignore reconnecting fewer children', () =>
369+
expectMarkupMismatch(
370370
<div>
371371
<div />
372372
<div />
@@ -376,8 +376,8 @@ describe('ReactDOMServerIntegration', () => {
376376
</div>,
377377
));
378378

379-
it('can explicitly ignore reconnecting reordered children', () =>
380-
expectMarkupMatch(
379+
it('can not ignore reconnecting reordered children', () =>
380+
expectMarkupMismatch(
381381
<div suppressHydrationWarning={true}>
382382
<div />
383383
<span />
@@ -456,3 +456,73 @@ describe('ReactDOMServerIntegration', () => {
456456
));
457457
});
458458
});
459+
460+
describe('ReactDOMServerIntegration (legacy)', () => {
461+
function initModules() {
462+
// Reset warning cache.
463+
jest.resetModules();
464+
465+
React = require('react');
466+
ReactDOM = require('react-dom');
467+
ReactDOMServer = require('react-dom/server');
468+
ReactTestUtils = require('react-dom/test-utils');
469+
470+
// Make them available to the helpers.
471+
return {
472+
ReactDOM,
473+
ReactDOMServer,
474+
ReactTestUtils,
475+
};
476+
}
477+
478+
const {resetModules, expectMarkupMatch} =
479+
ReactDOMServerIntegrationUtils(initModules);
480+
481+
beforeEach(() => {
482+
resetModules();
483+
});
484+
485+
it('legacy mode can explicitly ignore errors reconnecting different element types of children', () =>
486+
expectMarkupMatch(
487+
<div>
488+
<div />
489+
</div>,
490+
<div suppressHydrationWarning={true}>
491+
<span />
492+
</div>,
493+
));
494+
495+
it('legacy mode can explicitly ignore reconnecting more children', () =>
496+
expectMarkupMatch(
497+
<div>
498+
<div />
499+
</div>,
500+
<div suppressHydrationWarning={true}>
501+
<div />
502+
<div />
503+
</div>,
504+
));
505+
506+
it('legacy mode can explicitly ignore reconnecting fewer children', () =>
507+
expectMarkupMatch(
508+
<div>
509+
<div />
510+
<div />
511+
</div>,
512+
<div suppressHydrationWarning={true}>
513+
<div />
514+
</div>,
515+
));
516+
517+
it('legacy mode can explicitly ignore reconnecting reordered children', () =>
518+
expectMarkupMatch(
519+
<div suppressHydrationWarning={true}>
520+
<div />
521+
<span />
522+
</div>,
523+
<div suppressHydrationWarning={true}>
524+
<span />
525+
<div />
526+
</div>,
527+
));
528+
});

0 commit comments

Comments
 (0)