Skip to content

Commit

Permalink
补充双向绑定的测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
赵之琛 committed Oct 11, 2022
1 parent ae951fc commit ce980bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions questions/26-v-model/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const VOhModel = {
const value = ref("Hello Vue.js")
setTimeout(() => {
value.value = "Hello World!!!"
},2000)
</script>

<template>
Expand Down
10 changes: 10 additions & 0 deletions questions/26-v-model/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import { describe, it, expect } from "vitest"

import App from "./App.vue"

function delay(timeout: number) {
return new Promise((resolve) => {
setTimeout(resolve, timeout)
})
}

describe("v-model", () => {
it("should work", async() => {
const wrapper = mount(App)
Expand All @@ -15,5 +21,9 @@ describe("v-model", () => {
await input.setValue("Hello World")
expect(input.element.value).toBe("Hello World")
expect(p.text()).toBe(input.element.value)

await delay(2000)
expect(input.element.value).toBe("Hello World!!!")
expect(p.text()).toBe(input.element.value)
})
})

0 comments on commit ce980bd

Please sign in to comment.