Skip to content

Commit

Permalink
Add nested head content test
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp committed Mar 29, 2024
1 parent 5b3c8b7 commit 2974e55
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions internal/printer/printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3548,6 +3548,31 @@ const items = ["Dog", "Cat", "Platipus"];
code: `${$$renderComponent($$result,'Component',Component,{})}${(void 0)}`,
},
},
{
name: "nested head content stays in the head",
source: `---
const meta = { title: 'My App' };
---
<html>
<head>
<meta charset="utf-8" />
{
meta && <title>{meta.title}</title>
}
<meta name="after">
</head>
<body>
<h1>My App</h1>
</body>
</html>`,
want: want{
frontmatter: []string{"", `const meta = { title: 'My App' };`},
code: `<html> <head> <meta charset="utf-8"> ${ meta && $$render` + BACKTICK + `<title>${meta.title}</title>` + BACKTICK + ` } <meta name="after"> ${$$renderHead($$result)}</head> <body> <h1>My App</h1> </body></html>`,
},
},
}

for _, tt := range tests {
Expand Down Expand Up @@ -3578,6 +3603,7 @@ const items = ["Dog", "Cat", "Platipus"];
RenderScript: tt.transformOptions.RenderScript,
}
transform.Transform(doc, transformOptions, h) // note: we want to test Transform in context here, but more advanced cases could be tested separately

result := PrintToJS(code, doc, 0, transform.TransformOptions{
Scope: "XXXX",
InternalURL: "http://localhost:3000/",
Expand Down

0 comments on commit 2974e55

Please sign in to comment.