-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest-stacks.js
28 lines (26 loc) · 1.23 KB
/
test-stacks.js
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
26
27
28
import { test, expect } from 'vitest';
import { process } from './process.js';
test('`stack` and `push` tags', async () => {
process(
`<component src="layouts/base.html"><div>Main content</div><push name="head"><meta name="pushed" content="Content pushed"></push></component>`,
{
root: './test/templates',
tag: 'component'
}
)
.then(html => {
expect(html).toBe(`<html><head><title>Base Layout</title><meta name="pushed" content="Content pushed"></head><body><header></header><main><div>Main content</div></main><footer>footer content</footer></body></html>`);
});
});
test('`prepend` and `once` attributes on `push` tag', async () => {
process(
`<component src="layouts/base.html"><div>Main content</div><push name="head" prepend once><meta name="pushed" content="Content pushed"></push><push name="head" prepend once><meta name="pushed" content="Content pushed"></push></component>`,
{
root: './test/templates',
tag: 'component'
}
)
.then(html => {
expect(html).toBe(`<html><head><title>Base Layout</title><meta name="pushed" content="Content pushed"></head><body><header></header><main><div>Main content</div></main><footer>footer content</footer></body></html>`);
});
});