Skip to content

Commit

Permalink
add tests for resource emission when rendering no head or just a head (
Browse files Browse the repository at this point in the history
  • Loading branch information
gnoff authored Oct 5, 2022
1 parent 792343d commit e40893d
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMFloat-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down

0 comments on commit e40893d

Please sign in to comment.