File tree 1 file changed +54
-0
lines changed
packages/react-dom/src/__tests__
1 file changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,60 @@ describe('ReactDOMFloat', () => {
248
248
) ;
249
249
} ) ;
250
250
251
+ // @gate enableFloat
252
+ it ( 'emits resources before everything else when rendering with no head' , async ( ) => {
253
+ function App ( ) {
254
+ return (
255
+ < >
256
+ < title > foo</ title >
257
+ < link rel = "preload" href = "foo" as = "style" />
258
+ </ >
259
+ ) ;
260
+ }
261
+
262
+ await actIntoEmptyDocument ( ( ) => {
263
+ buffer = `<!DOCTYPE html><html><head>${ ReactDOMFizzServer . renderToString (
264
+ < App /> ,
265
+ ) } </head><body>foo</body></html>`;
266
+ } ) ;
267
+ expect ( getVisibleChildren ( document ) ) . toEqual (
268
+ < html >
269
+ < head >
270
+ < link rel = "preload" href = "foo" as = "style" />
271
+ < title > foo</ title >
272
+ </ head >
273
+ < body > foo</ body >
274
+ </ html > ,
275
+ ) ;
276
+ } ) ;
277
+
278
+ // @gate enableFloat
279
+ it ( 'emits resources before everything else when rendering with just a head' , async ( ) => {
280
+ function App ( ) {
281
+ return (
282
+ < head >
283
+ < title > foo</ title >
284
+ < link rel = "preload" href = "foo" as = "style" />
285
+ </ head >
286
+ ) ;
287
+ }
288
+
289
+ await actIntoEmptyDocument ( ( ) => {
290
+ buffer = `<!DOCTYPE html><html>${ ReactDOMFizzServer . renderToString (
291
+ < App /> ,
292
+ ) } <body>foo</body></html>`;
293
+ } ) ;
294
+ expect ( getVisibleChildren ( document ) ) . toEqual (
295
+ < html >
296
+ < head >
297
+ < link rel = "preload" href = "foo" as = "style" />
298
+ < title > foo</ title >
299
+ </ head >
300
+ < body > foo</ body >
301
+ </ html > ,
302
+ ) ;
303
+ } ) ;
304
+
251
305
describe ( 'HostResource' , ( ) => {
252
306
// @gate enableFloat
253
307
it ( 'warns when you update props to an invalid type' , async ( ) => {
You can’t perform that action at this time.
0 commit comments