mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
45 lines
991 B
TypeScript
45 lines
991 B
TypeScript
import type { UserEvent } from 'vitest/browser'
|
|
import type { UserEventCommand } from './utils'
|
|
|
|
export const click: UserEventCommand<UserEvent['click']> = async (
|
|
context,
|
|
selector,
|
|
options = {},
|
|
) => {
|
|
const browser = context.browser
|
|
await browser.$(selector).click(options as any)
|
|
}
|
|
|
|
export const dblClick: UserEventCommand<UserEvent['dblClick']> = async (
|
|
context,
|
|
selector,
|
|
_options = {},
|
|
) => {
|
|
const browser = context.browser
|
|
await browser.$(selector).doubleClick()
|
|
}
|
|
|
|
export const tripleClick: UserEventCommand<UserEvent['tripleClick']> = async (
|
|
context,
|
|
selector,
|
|
_options = {},
|
|
) => {
|
|
const browser = context.browser
|
|
await browser
|
|
.action('pointer', { parameters: { pointerType: 'mouse' } })
|
|
// move the pointer over the button
|
|
.move({ origin: browser.$(selector) })
|
|
// simulate 3 clicks
|
|
.down()
|
|
.up()
|
|
.pause(50)
|
|
.down()
|
|
.up()
|
|
.pause(50)
|
|
.down()
|
|
.up()
|
|
.pause(50)
|
|
// run the sequence
|
|
.perform()
|
|
}
|