From bc4f11c3ea78c91e7021df7a43a6c5e588cc4803 Mon Sep 17 00:00:00 2001 From: cuixiaorui Date: Tue, 26 Jul 2022 23:19:36 +0800 Subject: [PATCH] test: add test case for watchEffect --- packages/runtime-core/__tests__/apiWatch.spec.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 packages/runtime-core/__tests__/apiWatch.spec.ts diff --git a/packages/runtime-core/__tests__/apiWatch.spec.ts b/packages/runtime-core/__tests__/apiWatch.spec.ts new file mode 100644 index 0000000..b71d17e --- /dev/null +++ b/packages/runtime-core/__tests__/apiWatch.spec.ts @@ -0,0 +1,15 @@ +describe("api: watch", () => { + it.todo("effect", async () => { + // 先实现个 watchEffect 玩一玩 + const state = reactive({ count: 0 }); + let dummy; + watchEffect(() => { + dummy = state.count; + }); + expect(dummy).toBe(0); + + state.count++; + await nextTick(); + expect(dummy).toBe(1); + }); +});