Skip to content
Permalink
Browse files
add tests for resource emission when rendering no head or just a head (
  • Loading branch information
gnoff committed Oct 5, 2022
1 parent 792343d commit e40893d097f6894b4768d749f796302c57161734
Showing 1 changed file with 54 additions and 0 deletions.
@@ -248,6 +248,60 @@ describe('ReactDOMFloat', () => {
);
});

// @gate enableFloat
it('emits resources before everything else when rendering with no head', async () => {
function App() {
return (
<>
<title>foo</title>
<link rel="preload" href="foo" as="style" />
</>
);
}

await actIntoEmptyDocument(() => {
buffer = `<!DOCTYPE html><html><head>${ReactDOMFizzServer.renderToString(
<App />,
)}</head><body>foo</body></html>`;
});
expect(getVisibleChildren(document)).toEqual(
<html>
<head>
<link rel="preload" href="foo" as="style" />
<title>foo</title>
</head>
<body>foo</body>
</html>,
);
});

// @gate enableFloat
it('emits resources before everything else when rendering with just a head', async () => {
function App() {
return (
<head>
<title>foo</title>
<link rel="preload" href="foo" as="style" />
</head>
);
}

await actIntoEmptyDocument(() => {
buffer = `<!DOCTYPE html><html>${ReactDOMFizzServer.renderToString(
<App />,
)}<body>foo</body></html>`;
});
expect(getVisibleChildren(document)).toEqual(
<html>
<head>
<link rel="preload" href="foo" as="style" />
<title>foo</title>
</head>
<body>foo</body>
</html>,
);
});

describe('HostResource', () => {
// @gate enableFloat
it('warns when you update props to an invalid type', async () => {

0 comments on commit e40893d

Please sign in to comment.