Skip to content

Commit

Permalink
test: fix runtime-dom v-on test
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 7, 2020
1 parent 2302dea commit f87d6b5
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/runtime-dom/__tests__/directives/vOn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ describe('runtime-dom: v-on directive', () => {
const child = document.createElement('input')
parent.appendChild(child)
const childNextValue = withModifiers(jest.fn(), ['prevent', 'stop'])
patchEvent(child, 'click', null, childNextValue, null)
patchEvent(child, 'onClick', null, childNextValue, null)
const parentNextValue = jest.fn()
patchEvent(parent, 'click', null, parentNextValue, null)
patchEvent(parent, 'onClick', null, parentNextValue, null)
expect(triggerEvent(child, 'click').defaultPrevented).toBe(true)
expect(parentNextValue).not.toBeCalled()
})
Expand All @@ -35,7 +35,7 @@ describe('runtime-dom: v-on directive', () => {
parent.appendChild(child)
const fn = jest.fn()
const handler = withModifiers(fn, ['self'])
patchEvent(parent, 'click', null, handler, null)
patchEvent(parent, 'onClick', null, handler, null)
triggerEvent(child, 'click')
expect(fn).not.toBeCalled()
})
Expand All @@ -48,7 +48,7 @@ describe('runtime-dom: v-on directive', () => {
'esc',
'arrow-left'
])
patchEvent(el, 'keyup', null, nextValue, null)
patchEvent(el, 'onKeyup', null, nextValue, null)

triggerEvent(el, 'keyup', e => (e.key = 'a'))
expect(fn).not.toBeCalled()
Expand Down Expand Up @@ -77,15 +77,15 @@ describe('runtime-dom: v-on directive', () => {
// Case 1: <div @keyup.exact="test"/>
const fn1 = jest.fn()
const next1 = withModifiers(fn1, ['exact'])
patchEvent(el, 'keyup', null, next1, null)
patchEvent(el, 'onKeyup', null, next1, null)
triggerEvent(el, 'keyup')
expect(fn1.mock.calls.length).toBe(1)
triggerEvent(el, 'keyup', e => (e.ctrlKey = true))
expect(fn1.mock.calls.length).toBe(1)
// Case 2: <div @keyup.ctrl.a.exact="test"/>
const fn2 = jest.fn()
const next2 = withKeys(withModifiers(fn2, ['ctrl', 'exact']), ['a'])
patchEvent(el, 'keyup', null, next2, null)
patchEvent(el, 'onKeyup', null, next2, null)
triggerEvent(el, 'keyup', e => (e.key = 'a'))
expect(fn2).not.toBeCalled()
triggerEvent(el, 'keyup', e => {
Expand All @@ -109,7 +109,7 @@ describe('runtime-dom: v-on directive', () => {
const el = document.createElement('div')
const fn = jest.fn()
const handler = withModifiers(fn, [button])
patchEvent(el, 'mousedown', null, handler, null)
patchEvent(el, 'onMousedown', null, handler, null)
buttons.filter(b => b !== button).forEach(button => {
triggerEvent(el, 'mousedown', e => (e.button = buttonCodes[button]))
})
Expand Down

0 comments on commit f87d6b5

Please sign in to comment.