Skip to content

Commit 190e76c

Browse files
committed
add a test case for calling the debug function multiple times
1 parent dac1767 commit 190e76c

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

packages/runtime-core/__tests__/debug.spec.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,36 @@ describe('debug', () => {
3131
name: 'foo',
3232
})
3333
})
34+
test('watching states with calling the debug function multiple times', () => {
35+
const root = nodeOps.createElement('div')
36+
let instance: ComponentInternalInstance
37+
const Comp = defineComponent({
38+
setup() {
39+
const name = ref('foo')
40+
const age = ref(100)
41+
debug({
42+
name,
43+
})
44+
debug({
45+
age,
46+
name,
47+
})
48+
debug({
49+
name,
50+
})
51+
return () => (
52+
h('div', name.value)
53+
)
54+
},
55+
mounted() {
56+
instance = getCurrentInstance()!
57+
},
58+
})
59+
render(h(Comp), root)
60+
expect(inner(root)).toBe('<div>foo</div>')
61+
expect(instance!.setupState).toEqual({
62+
name: 'foo',
63+
age: 100,
64+
})
65+
})
3466
})

packages/runtime-core/src/debug.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {getCurrentInstance} from './component'
66
* @example
77
* const Component = defineComponent({
88
* setup() {
9-
* const name = ref('foo')
9+
* const name = ref('foo')
1010
* debug({
1111
* // watch states in the vue devtool
1212
* name,

0 commit comments

Comments
 (0)