Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit cb97d75

Browse files
authoredJul 12, 2022
test: add test case for Q25 (webfansplz#594)
1 parent 360578f commit cb97d75

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed
 

‎questions/25-useMouse/README.md

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎questions/25-useMouse/README.zh-CN.md

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎questions/25-useMouse/index.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { mount } from "@vue/test-utils"
2+
import { describe, it, expect } from "vitest"
3+
import { nextTick } from "vue"
4+
5+
import App from "./App.vue"
6+
7+
describe("useMouse", () => {
8+
it("should work", async() => {
9+
const wrapper = mount(App)
10+
expect(wrapper.html()).toBe("Mouse position is at: 0, 0")
11+
12+
const mousemove = new MouseEvent("mousemove", {
13+
screenX: 10,
14+
screenY: 20,
15+
clientX: 10,
16+
clientY: 20,
17+
})
18+
window.dispatchEvent(mousemove)
19+
20+
await nextTick()
21+
expect(wrapper.html()).toBe("Mouse position is at: 10, 20")
22+
})
23+
})

0 commit comments

Comments
 (0)