Skip to content

Commit ce980bd

Browse files
author
赵之琛
committed
补充双向绑定的测试用例
1 parent ae951fc commit ce980bd

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

questions/26-v-model/App.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const VOhModel = {
1313
1414
const value = ref("Hello Vue.js")
1515
16+
setTimeout(() => {
17+
value.value = "Hello World!!!"
18+
},2000)
19+
1620
</script>
1721

1822
<template>

questions/26-v-model/index.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import { describe, it, expect } from "vitest"
33

44
import App from "./App.vue"
55

6+
function delay(timeout: number) {
7+
return new Promise((resolve) => {
8+
setTimeout(resolve, timeout)
9+
})
10+
}
11+
612
describe("v-model", () => {
713
it("should work", async() => {
814
const wrapper = mount(App)
@@ -15,5 +21,9 @@ describe("v-model", () => {
1521
await input.setValue("Hello World")
1622
expect(input.element.value).toBe("Hello World")
1723
expect(p.text()).toBe(input.element.value)
24+
25+
await delay(2000)
26+
expect(input.element.value).toBe("Hello World!!!")
27+
expect(p.text()).toBe(input.element.value)
1828
})
1929
})

0 commit comments

Comments
 (0)