-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmisc_spec.js
52 lines (47 loc) · 1.31 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
// patch inDoc
require('../lib/indoc_patch')
// 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 = '<div v-component="outter" v-ref="outter"><div v-component="inner"></div></div>'
document.body.appendChild(el)
var vm = new Vue({
el: el,
components: {
outter: {
template: '<content></content>'
},
inner: {
template: 'hi',
attached: spy1,
detached: spy2
}
}
})
expect(spy1).toHaveBeenCalled()
vm.$.outter.$remove()
expect(spy2).toHaveBeenCalled()
})
})