Skip to content

Commit

Permalink
add a test case for calling the debug function multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
bichikim committed Mar 10, 2022
1 parent dac1767 commit 190e76c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
32 changes: 32 additions & 0 deletions packages/runtime-core/__tests__/debug.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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('<div>foo</div>')
expect(instance!.setupState).toEqual({
name: 'foo',
age: 100,
})
})
})
2 changes: 1 addition & 1 deletion packages/runtime-core/src/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 190e76c

Please sign in to comment.