Skip to content

Commit cee5b57

Browse files
committed
test switching handlers for v-events
1 parent af0f69a commit cee5b57

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/unit/specs/directives/events_spec.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,39 @@ if (_.inBrowser) {
9090
})
9191
})
9292

93+
it('should be able to switch handlers if not a method', function (done) {
94+
var a = 0
95+
var b = 0
96+
var vm = new Vue({
97+
el: el,
98+
data: {
99+
handle: function () {
100+
a++
101+
}
102+
},
103+
template: '<div v-component="test" v-events="test:handle"></div>',
104+
components: {
105+
test: {
106+
compiled: function () {
107+
this.$emit('test')
108+
}
109+
}
110+
}
111+
})
112+
_.nextTick(function () {
113+
expect(a).toBe(1)
114+
expect(b).toBe(0)
115+
vm.handle = function () {
116+
b++
117+
}
118+
_.nextTick(function () {
119+
vm._children[0].$emit('test')
120+
expect(a).toBe(1)
121+
expect(b).toBe(1)
122+
done()
123+
})
124+
})
125+
})
126+
93127
})
94128
}

0 commit comments

Comments
 (0)