Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions internal/printer/printer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3803,6 +3803,16 @@ const c = '\''
source: `<main id=` + BACKTICK + `gotcha />`,
want: []ASTNode{{Type: "element", Name: "main", Attributes: []ASTNode{{Type: "attribute", Kind: "template-literal", Name: "id", Value: "gotcha", Raw: "`gotcha"}}}},
},
{
name: "text with <",
source: `<span>n <value </span>`,
want: []ASTNode{{Type: "element", Name: "span", Children: []ASTNode{{Type: "text", Value: "n <value "}}}},
},
{
name: "unclosed element",
source: "<div class=\"name\"\n<h1 />",
want: []ASTNode{{Type: "element", Name: "div", Attributes: []ASTNode{{Type: "attribute", Kind: "quoted", Name: "class", Value: "name", Raw: `"name"`}}, Children: []ASTNode{{Type: "element", Name: "h1"}}}},
},
}

for _, tt := range tests {
Expand Down
15 changes: 15 additions & 0 deletions internal/token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,21 @@ func TestBasic(t *testing.T) {
`<div></div><MyAstroComponent` + "\n",
[]TokenType{StartTagToken, EndTagToken, TextToken},
},
{
"incomplete tag IV",
`<span>n < value</span>`,
[]TokenType{StartTagToken, TextToken, EndTagToken},
},
{
"incomplete tag V",
`<span>n<value</span>`,
[]TokenType{StartTagToken, TextToken, EndTagToken},
},
{
"incomplete tag V",
"<div class=\"name\"\n<h1 />",
[]TokenType{StartTagToken, TextToken, SelfClosingTagToken},
},
}

runTokenTypeTest(t, Basic)
Expand Down