-
-
Notifications
You must be signed in to change notification settings - Fork 189
/
Copy pathindex.test.ts
36 lines (31 loc) · 1.11 KB
/
index.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { mount } from "@vue/test-utils"
import { describe, it, expect, vi } from "vitest"
import App from "./App.vue"
describe("key modifiers", () => {
it("should work", async() => {
let printLog = ""
console.log = vi.fn(
(log: string) => {
printLog = log?.toString()?.trim()
})
const wrapper = mount(App)
const buttons = wrapper.findAll("button")
await buttons[0].trigger('click')
expect(printLog).toMatchInlineSnapshot('""')
printLog = ""
await buttons[0].trigger('click.alt')
expect(printLog).toMatchInlineSnapshot('"onClick1"')
printLog = ""
await buttons[0].trigger('click.shift')
expect(printLog).toMatchInlineSnapshot('"onClick1"')
printLog = ""
await buttons[0].trigger('click.shift.alt')
expect(printLog).toMatchInlineSnapshot('"onClick1"')
await buttons[1].trigger('click')
expect(printLog).toMatchInlineSnapshot('"onClick1"')
await buttons[1].trigger('click.shift')
expect(printLog).toMatchInlineSnapshot('"onCtrlClick"')
await buttons[2].trigger('click')
expect(printLog).toMatchInlineSnapshot('"onClick2"')
})
})