From: zqran <215244947@qq.com> Date: Tue, 11 Jul 2023 09:37:56 +0000 (+0800) Subject: test(reactivity): use vitest fn instead of counting manually (#8476) X-Git-Tag: v3.3.5~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c2e44ff5f10e2d381b503979f6193f6c20fa4c1;p=thirdparty%2Fvuejs%2Fcore.git test(reactivity): use vitest fn instead of counting manually (#8476) --- diff --git a/packages/reactivity/__tests__/ref.spec.ts b/packages/reactivity/__tests__/ref.spec.ts index b0ba9d9cb1..0ee32866da 100644 --- a/packages/reactivity/__tests__/ref.spec.ts +++ b/packages/reactivity/__tests__/ref.spec.ts @@ -28,19 +28,18 @@ describe('reactivity/ref', () => { it('should be reactive', () => { const a = ref(1) let dummy - let calls = 0 - effect(() => { - calls++ + const fn = vi.fn(() => { dummy = a.value }) - expect(calls).toBe(1) + effect(fn) + expect(fn).toHaveBeenCalledTimes(1) expect(dummy).toBe(1) a.value = 2 - expect(calls).toBe(2) + expect(fn).toHaveBeenCalledTimes(2) expect(dummy).toBe(2) // same value should not trigger a.value = 2 - expect(calls).toBe(2) + expect(fn).toHaveBeenCalledTimes(2) }) it('should make nested properties reactive', () => {