Skip to content

Commit 8db0989

Browse files
committed
test: add test
1 parent f984094 commit 8db0989

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6290,6 +6290,45 @@ body {
62906290
' in App (at **)',
62916291
]);
62926292
});
6293+
6294+
it('supports nonce', async () => {
6295+
function App({url}) {
6296+
ReactDOM.preloadModule(url, {as: 'script', nonce: 'abc'});
6297+
return 'hello';
6298+
}
6299+
6300+
await act(() => {
6301+
renderToPipeableStream(<App url="server" />).pipe(writable);
6302+
});
6303+
6304+
expect(getMeaningfulChildren(document)).toEqual(
6305+
<html>
6306+
<head />
6307+
<body>
6308+
<div id="container">
6309+
<link rel="modulepreload" href="server" nonce="abc" />
6310+
hello
6311+
</div>
6312+
</body>
6313+
</html>,
6314+
);
6315+
6316+
ReactDOMClient.hydrateRoot(container, <App url="client" />);
6317+
await waitForAll([]);
6318+
expect(getMeaningfulChildren(document)).toEqual(
6319+
<html>
6320+
<head>
6321+
<link rel="modulepreload" href="client" nonce="abc" />
6322+
</head>
6323+
<body>
6324+
<div id="container">
6325+
<link rel="modulepreload" href="server" nonce="abc" />
6326+
hello
6327+
</div>
6328+
</body>
6329+
</html>,
6330+
);
6331+
});
62936332
});
62946333

62956334
describe('ReactDOM.preinit(href, { as: ... })', () => {

0 commit comments

Comments
 (0)