-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc_spec.js
68 lines (62 loc) · 1.71 KB
/
misc_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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// test cases for edge cases & bug fixes
var Vue = require('../../../src/vue')
describe('Misc', function () {
it('should handle directive.bind() altering its childNode structure', function () {
var vm = new Vue({
el: document.createElement('div'),
template: '<div v-test>{{test}}</div>',
data: {
test: 'hi'
},
directives: {
test: {
bind: function () {
this.el.insertBefore(document.createTextNode('yo '),
this.el.firstChild)
}
}
}
})
expect(vm.$el.textContent).toBe('yo hi')
})
it('attached/detached hooks for transcluded components', function () {
var spy1 = jasmine.createSpy('attached')
var spy2 = jasmine.createSpy('detached')
var el = document.createElement('div')
el.innerHTML = '<outer v-ref="outter"><inner></inner></outer>'
document.body.appendChild(el)
var vm = new Vue({
el: el,
components: {
outer: {
template: '<content></content>'
},
inner: {
template: 'hi',
attached: spy1,
detached: spy2
}
}
})
expect(spy1).toHaveBeenCalled()
vm.$.outter.$remove()
expect(spy2).toHaveBeenCalled()
})
it('v-repeat on component root node with replace:true', function () {
var el = document.createElement('div')
var vm = new Vue({
el: el,
template: '<test></test>',
components: {
test: {
data: function () {
return { list: [1, 2, 3] }
},
template: '<div v-repeat="list">{{$value}}</div>',
replace: true
}
}
})
expect(vm.$el.innerHTML).toBe('<div>1</div><div>2</div><div>3</div>')
})
})