@@ -49,6 +49,37 @@ describe('renderToString', () => {
49
49
) ;
50
50
} ) ;
51
51
52
+ it ( 'puts style last in the head tag' , async ( ) => {
53
+ const { html } = await renderToString (
54
+ `<html>
55
+ <head>
56
+ <link rel="preconnect" href="https://some-url.com" />
57
+ </head>
58
+
59
+ <body>
60
+ <div class="__next">
61
+ <main>
62
+ <scoped-car-list cars=${ JSON . stringify ( [ vento , beetle ] ) } ></scoped-car-list>
63
+ </main>
64
+ </div>
65
+
66
+ <script type="module">
67
+ import { defineCustomElements } from "./static/loader/index.js";
68
+ defineCustomElements().catch(console.error);
69
+ </script>
70
+ </body>
71
+ </html>` ,
72
+ { fullDocument : true , serializeShadowRoot : false } ,
73
+ ) ;
74
+
75
+ expect ( html ) . toContain (
76
+ '<link rel="preconnect" href="https://some-url.com"> <style sty-id="sc-scoped-car-list">.sc-scoped-car-list-h{' ,
77
+ ) ;
78
+ expect ( html ) . toContain (
79
+ '.selected.sc-scoped-car-list{font-weight:bold;background:rgb(255, 255, 210)}</style></head> <body> <div class="__next"> <main> <scoped-car-list cars' ,
80
+ ) ;
81
+ } ) ;
82
+
52
83
it ( 'allows to hydrate whole HTML page with using a scoped component' , async ( ) => {
53
84
const { html } = await renderToString (
54
85
`<html>
@@ -79,7 +110,7 @@ describe('renderToString', () => {
79
110
* renders hydration styles and custom link tag within the head tag
80
111
*/
81
112
expect ( html ) . toContain (
82
- '. selected.sc-scoped-car-list{font-weight:bold;background:rgb(255, 255, 210)}</style><link rel="stylesheet" href="whatever.css"> </head> <body> <div class="__next"> <main> <scoped-car-list cars=' ,
113
+ '<link rel="stylesheet" href="whatever.css"> <style sty-id="sc-scoped-car-list">.sc-scoped-car-list-h{display:block;margin:10px;padding:10px;border:1px solid blue}ul.sc-scoped-car-list{display:block;margin:0;padding:0}li.sc-scoped-car-list{list-style:none;margin:0;padding:20px}. selected.sc-scoped-car-list{font-weight:bold;background:rgb(255, 255, 210)}</style></head> <body> <div class="__next"> <main> <scoped-car-list cars=' ,
83
114
) ;
84
115
} ) ;
85
116
} ) ;
0 commit comments