Skip to content

Commit

Permalink
fix v-on unit test (vuejs#5144)
Browse files Browse the repository at this point in the history
  • Loading branch information
javoski authored and yyx990803 committed Mar 10, 2017
1 parent 8fca83d commit f9706dc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions test/unit/features/directives/on.spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import Vue from 'vue'

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

beforeEach(() => {
spy = jasmine.createSpy()
spy2 = jasmine.createSpy()
el = document.createElement('div')
document.body.appendChild(el)
})
Expand Down Expand Up @@ -88,12 +87,15 @@ describe('Directive v-on', () => {
template: `
<input type="checkbox" ref="input" @click.prevent="foo">
`,
methods: { foo: spy2 }
methods: {
foo ($event) {
spy($event.defaultPrevented)
}
}
})
vm.$refs.input.checked = false
triggerEvent(vm.$refs.input, 'click')
expect(spy2).toHaveBeenCalled()
expect(vm.$refs.input.checked).toBe(false)
expect(spy).toHaveBeenCalledWith(true)
})

it('should support capture', () => {
Expand Down

0 comments on commit f9706dc

Please sign in to comment.