element-plus/packages/test-utils/composite-click.ts
三咲智子 55348b30b6
style: use prettier (#3228)
* style: use prettier

* style: just prettier format, no code changes

* style: eslint fix
object-shorthand, prefer-const

* style: fix no-void

* style: no-console
2021-09-04 19:29:28 +08:00

26 lines
613 B
TypeScript

import { nextTick } from 'vue'
import triggerEvent from './trigger-event'
import type { DOMWrapper, VueWrapper } from '@vue/test-utils'
const triggerCompositeClick = async <
T extends VueWrapper<any> | DOMWrapper<Element>
>(
wrapper: T
) => {
await wrapper.trigger('mousedown')
await wrapper.trigger('mouseup')
await wrapper.trigger('click')
}
export default triggerCompositeClick
export const triggerNativeCompositeClick = async (el: Element) => {
triggerEvent(el, 'mousedown')
await nextTick()
triggerEvent(el, 'mouseup')
await nextTick()
triggerEvent(el, 'click')
return nextTick()
}