-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7db9a1d
commit 3ad3cfa
Showing
2 changed files
with
106 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { parse, render } from "../src"; | ||
import { describe, expect, it, test } from "vitest"; | ||
|
||
describe("astro", () => { | ||
it("handles expressions", async () => { | ||
const input = `--- | ||
let value: string; | ||
--- | ||
<h1>Hello {world}</h1> | ||
<Component a="1" b="2" c={\`three\`} items={astro.map((item: string) => { | ||
const value: string = item.split('').reverse().join(''); | ||
return value; | ||
})}>Hello world</Component>`; | ||
const doc = parse(input); | ||
const output = await render(doc); | ||
expect(output).toEqual(input); | ||
}); | ||
|
||
it("does not hang on unmatched braces", async () => { | ||
const input = `--- | ||
let value: string; | ||
--- | ||
<h1>Hello {world}</h1> | ||
<Component a="1" b="2" c={\`three\`} items={astro.map((item: string) => { | ||
const value: string = item.split('{').reverse().join('{'); | ||
return value; | ||
})}>Hello world</Component>`; | ||
const doc = parse(input); | ||
const output = await render(doc); | ||
expect(output).toEqual(input); | ||
}); | ||
}); | ||
|