Skip to content

Commit bfecd08

Browse files
committed
fix more tests
1 parent 56acc51 commit bfecd08

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
210210
);
211211
});
212212

213+
// @gate enableClientRenderFallbackOnTextMismatch
213214
it('suppresses but does not fix multiple text node mismatches with suppressHydrationWarning', async () => {
214215
function App({isClient}) {
215216
return (
@@ -251,6 +252,48 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
251252
);
252253
});
253254

255+
// @gate !enableClientRenderFallbackOnTextMismatch
256+
it('suppresses and fixes multiple text node mismatches with suppressHydrationWarning', async () => {
257+
function App({isClient}) {
258+
return (
259+
<div>
260+
<span suppressHydrationWarning={true}>
261+
{isClient ? 'Client1' : 'Server1'}
262+
{isClient ? 'Client2' : 'Server2'}
263+
</span>
264+
</div>
265+
);
266+
}
267+
await act(() => {
268+
const {pipe} = ReactDOMFizzServer.renderToPipeableStream(
269+
<App isClient={false} />,
270+
);
271+
pipe(writable);
272+
});
273+
expect(getVisibleChildren(container)).toEqual(
274+
<div>
275+
<span>
276+
{'Server1'}
277+
{'Server2'}
278+
</span>
279+
</div>,
280+
);
281+
ReactDOMClient.hydrateRoot(container, <App isClient={true} />, {
282+
onRecoverableError(error) {
283+
Scheduler.log(error.message);
284+
},
285+
});
286+
await waitForAll([]);
287+
expect(getVisibleChildren(container)).toEqual(
288+
<div>
289+
<span>
290+
{'Client1'}
291+
{'Client2'}
292+
</span>
293+
</div>,
294+
);
295+
});
296+
254297
it('errors on text-to-element mismatches with suppressHydrationWarning', async () => {
255298
function App({isClient}) {
256299
return (

0 commit comments

Comments
 (0)