From dac1767278975398dc00cd272d93a1d613700197 Mon Sep 17 00:00:00 2001 From: Bichi Kim Date: Sun, 20 Feb 2022 01:02:27 +0900 Subject: [PATCH] add debug testing --- packages/runtime-core/__tests__/debug.spec.ts | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 packages/runtime-core/__tests__/debug.spec.ts diff --git a/packages/runtime-core/__tests__/debug.spec.ts b/packages/runtime-core/__tests__/debug.spec.ts new file mode 100644 index 00000000000..f378b70c36d --- /dev/null +++ b/packages/runtime-core/__tests__/debug.spec.ts @@ -0,0 +1,34 @@ +import {debug} from '../src/debug' +import { + h, + render, + defineComponent, + ref, getCurrentInstance, ComponentInternalInstance, nodeOps, + serializeInner as inner +} from '@vue/runtime-test' + +describe('debug', () => { + test('watching states', () => { + const root = nodeOps.createElement('div') + let instance: ComponentInternalInstance + const Comp = defineComponent({ + setup() { + const name = ref('foo') + 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', + }) + }) +})