-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathcustom-augmentations.test.ts
42 lines (39 loc) · 1.07 KB
/
custom-augmentations.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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { createSSRApp, ref } from 'vue'
import { renderToString } from '@vue/server-renderer'
import type { MergeHead } from '@unhead/vue'
import { createHead, renderHeadToString, useHead } from '../src'
describe('custom augmentation', () => {
test('link auto-completion', async () => {
interface CustomHead extends MergeHead {
link: {
href: 'link-one' | 'link/two' | 'link/number/three'
}
}
const head = createHead<CustomHead>()
const app = createSSRApp({
setup() {
const title = ref('')
useHead<CustomHead>({
title: title.value,
link: [
{
'data-test': () => 'test',
'href': 'link-one',
},
],
})
title.value = 'hello'
return () => '<div>hi</div>'
},
})
app.use(head)
await renderToString(app)
const headResult = await renderHeadToString(head)
expect(headResult.headTags).toMatchInlineSnapshot(
`
"<title></title>
<link data-test=\\"test\\" href=\\"link-one\\">"
`,
)
})
})