Skip to content

Commit f9706dc

Browse files
javoskiyyx990803
authored andcommitted
fix v-on unit test (vuejs#5144)
1 parent 8fca83d commit f9706dc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

test/unit/features/directives/on.spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import Vue from 'vue'
22

33
describe('Directive v-on', () => {
4-
let vm, spy, spy2, el
4+
let vm, spy, el
55

66
beforeEach(() => {
77
spy = jasmine.createSpy()
8-
spy2 = jasmine.createSpy()
98
el = document.createElement('div')
109
document.body.appendChild(el)
1110
})
@@ -88,12 +87,15 @@ describe('Directive v-on', () => {
8887
template: `
8988
<input type="checkbox" ref="input" @click.prevent="foo">
9089
`,
91-
methods: { foo: spy2 }
90+
methods: {
91+
foo ($event) {
92+
spy($event.defaultPrevented)
93+
}
94+
}
9295
})
9396
vm.$refs.input.checked = false
9497
triggerEvent(vm.$refs.input, 'click')
95-
expect(spy2).toHaveBeenCalled()
96-
expect(vm.$refs.input.checked).toBe(false)
98+
expect(spy).toHaveBeenCalledWith(true)
9799
})
98100

99101
it('should support capture', () => {

0 commit comments

Comments
 (0)