forked from natemoo-re/ultrahtml
-
Notifications
You must be signed in to change notification settings - Fork 0
/
html.test.ts
25 lines (24 loc) · 811 Bytes
/
html.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { html, attrs } from "../src/";
import { describe, expect, it } from "vitest";
describe("html", () => {
it("works", () => {
const { value } = html`<h1>${"Hello world!"}</h1>`;
expect(value).toEqual(`<h1>Hello world!</h1>`);
})
it("escapes", () => {
const { value } = html`<h1>${"<div></div>"}</h1>`;
expect(value).toEqual(`<h1><div></div></h1>`);
})
it("nested", () => {
const { value } = html`<h1>${html`<div></div>`}</h1>`;
expect(value).toEqual(`<h1><div></div></h1>`);
})
it("attrs", () => {
const { value } = html`<h1 ${attrs({ hey: 'ya' })}></h1>`;
expect(value).toEqual(`<h1 hey="ya"></h1>`);
})
it("spread", () => {
const { value } = html`<h1 ...${{ hey: 'ya' }}></h1>`;
expect(value).toEqual(`<h1 hey="ya"></h1>`);
})
});