From 190e76c3e65bcd016b121f3a11d877ba83e29d49 Mon Sep 17 00:00:00 2001 From: bichikim Date: Thu, 10 Mar 2022 23:10:33 +0900 Subject: [PATCH] add a test case for calling the debug function multiple times --- packages/runtime-core/__tests__/debug.spec.ts | 32 +++++++++++++++++++ packages/runtime-core/src/debug.ts | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/packages/runtime-core/__tests__/debug.spec.ts b/packages/runtime-core/__tests__/debug.spec.ts index f378b70c36d..bb98d0cc138 100644 --- a/packages/runtime-core/__tests__/debug.spec.ts +++ b/packages/runtime-core/__tests__/debug.spec.ts @@ -31,4 +31,36 @@ describe('debug', () => { name: 'foo', }) }) + test('watching states with calling the debug function multiple times', () => { + const root = nodeOps.createElement('div') + let instance: ComponentInternalInstance + const Comp = defineComponent({ + setup() { + const name = ref('foo') + const age = ref(100) + debug({ + name, + }) + debug({ + age, + name, + }) + debug({ + name, + }) + return () => ( + h('div', name.value) + ) + }, + mounted() { + instance = getCurrentInstance()! + }, + }) + render(h(Comp), root) + expect(inner(root)).toBe('
foo
') + expect(instance!.setupState).toEqual({ + name: 'foo', + age: 100, + }) + }) }) diff --git a/packages/runtime-core/src/debug.ts b/packages/runtime-core/src/debug.ts index 781d0f186a6..7e476ed5172 100644 --- a/packages/runtime-core/src/debug.ts +++ b/packages/runtime-core/src/debug.ts @@ -6,7 +6,7 @@ import {getCurrentInstance} from './component' * @example * const Component = defineComponent({ * setup() { - * const name = ref('foo') + * const name = ref('foo') * debug({ * // watch states in the vue devtool * name,