forked from vuejs/vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpre.spec.js
45 lines (42 loc) · 1.14 KB
/
pre.spec.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import Vue from 'vue'
describe('Directive v-pre', function () {
it('should not compile inner content', function () {
const vm = new Vue({
template: `<div>
<div v-pre>{{ a }}</div>
<div>{{ a }}</div>
<div v-pre>
<component is="div"></component>
</div>
</div>`,
data: {
a: 123
}
})
vm.$mount()
expect(vm.$el.firstChild.textContent).toBe('{{ a }}')
expect(vm.$el.children[1].textContent).toBe('123')
expect(vm.$el.lastChild.innerHTML).toBe('<component is="div"></component>')
})
it('should not compile on root node', function () {
const vm = new Vue({
template: '<div v-pre>{{ a }}</div>',
replace: true,
data: {
a: 123
}
})
vm.$mount()
expect(vm.$el.firstChild.textContent).toBe('{{ a }}')
})
// #8286
it('should not compile custom component tags', function () {
Vue.component('vtest', { template: ` <div>Hello World</div>` })
const vm = new Vue({
template: '<div v-pre><vtest></vtest></div>',
replace: true
})
vm.$mount()
expect(vm.$el.firstChild.tagName).toBe('VTEST')
})
})