-
Notifications
You must be signed in to change notification settings - Fork 233
/
html.spec.ts
84 lines (73 loc) · 1.94 KB
/
html.spec.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { defineComponent, h } from 'vue'
import { mount } from '../src'
describe('html', () => {
it('returns html when mounting single root node', () => {
const Component = defineComponent({
render() {
return h('div', {}, 'Text content')
}
})
const wrapper = mount(Component)
expect(wrapper.html()).toBe('<div>Text content</div>')
})
it('returns the html when mounting multiple root nodes', () => {
const Component = defineComponent({
render() {
return [h('div', {}, 'foo'), h('div', {}, 'bar'), h('div', {}, 'baz')]
}
})
const wrapper = mount(Component)
expect(wrapper.html()).toBe(
'<div>foo</div>\n' + '<div>bar</div>\n' + '<div>baz</div>'
)
})
it('returns the html when mounting a Suspense component', () => {
const Foo = {
template: '<div class="Foo">FOO</div>',
setup() {
return {}
}
}
const Component = {
template: `
<Suspense>
<template #default>
<Foo />
</template>
<template #fallback>
Fallback
</template>
</Suspense>`,
components: { Foo }
}
const wrapper = mount(Component)
expect(wrapper.html()).toEqual('<div class="Foo">FOO</div>')
})
it('returns the html with findComponent in a nested Suspense component', () => {
const Foo = defineComponent({
template: '<div class="Foo">FOO</div>',
setup() {
return {}
}
})
const Component = {
template: `
<div>
<span>
<Suspense>
<template #default>
<Foo />
</template>
<template #fallback>
Fallback
</template>
</Suspense>
</span>
</div>`,
components: { Foo }
}
const wrapper = mount(Component)
const foo = wrapper.findComponent(Foo)
expect(foo.html()).toEqual('<div class="Foo">FOO</div>')
})
})