Skip to content

Commit 7c2e44f

Browse files
authored
test(reactivity): use vitest fn instead of counting manually (#8476)
1 parent 701fa73 commit 7c2e44f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

packages/reactivity/__tests__/ref.spec.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,18 @@ describe('reactivity/ref', () => {
2828
it('should be reactive', () => {
2929
const a = ref(1)
3030
let dummy
31-
let calls = 0
32-
effect(() => {
33-
calls++
31+
const fn = vi.fn(() => {
3432
dummy = a.value
3533
})
36-
expect(calls).toBe(1)
34+
effect(fn)
35+
expect(fn).toHaveBeenCalledTimes(1)
3736
expect(dummy).toBe(1)
3837
a.value = 2
39-
expect(calls).toBe(2)
38+
expect(fn).toHaveBeenCalledTimes(2)
4039
expect(dummy).toBe(2)
4140
// same value should not trigger
4241
a.value = 2
43-
expect(calls).toBe(2)
42+
expect(fn).toHaveBeenCalledTimes(2)
4443
})
4544

4645
it('should make nested properties reactive', () => {

0 commit comments

Comments
 (0)