Skip to content

Commit 80dac93

Browse files
authored
test: add test for Q232 (webfansplz#604)
1 parent 000d0dc commit 80dac93

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { mount } from "@vue/test-utils"
2+
import { describe, it, expect, vi } from "vitest"
3+
4+
import App from "./App.vue"
5+
6+
describe("key modifiers", () => {
7+
it("should work", async() => {
8+
let printLog = ""
9+
console.log = vi.fn(
10+
(log: string) => {
11+
printLog = log?.toString()?.trim()
12+
})
13+
const wrapper = mount(App)
14+
const buttons = wrapper.findAll("button")
15+
16+
await buttons[0].trigger('click')
17+
expect(printLog).toMatchInlineSnapshot('""')
18+
await buttons[0].trigger('click.alt')
19+
expect(printLog).toMatchInlineSnapshot('"onClick1"')
20+
await buttons[0].trigger('click.shift')
21+
expect(printLog).toMatchInlineSnapshot('"onClick1"')
22+
23+
await buttons[1].trigger('click')
24+
expect(printLog).toMatchInlineSnapshot('"onClick1"')
25+
await buttons[1].trigger('click.shift')
26+
expect(printLog).toMatchInlineSnapshot('"onCtrlClick"')
27+
28+
await buttons[2].trigger('click')
29+
expect(printLog).toMatchInlineSnapshot('"onClick2"')
30+
})
31+
})

0 commit comments

Comments
 (0)