-
-
Notifications
You must be signed in to change notification settings - Fork 189
/
Copy pathindex.test.ts
33 lines (29 loc) · 868 Bytes
/
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
import type { Ref } from "vue"
import { mount } from "@vue/test-utils"
import { describe, it, expect, vi } from "vitest"
import RefFamily from "./App.vue"
interface RefFamilyType {
count: Ref<number>
initial: Ref<number>
update: (value: number) => void
initialCount: (value: number | Ref<number>) => number
state: {foo: number; bar: number}
fooRef: Ref<number>
}
describe("RefFamily", () => {
it("update ref function", () => {
const wrapper = mount(RefFamily);
(wrapper.vm as unknown as RefFamilyType).update(996)
expect((wrapper.vm as unknown as RefFamilyType).count).toBe(996)
})
it("should work", () => {
const result: string[] = []
console.log = vi.fn((log: string) => {
result.push(log)
})
mount(RefFamily)
expect(JSON.stringify(result)).toBe(JSON.stringify([
1, true, true, true,
]))
})
})