Skip to content

Commit

Permalink
add debug testing
Browse files Browse the repository at this point in the history
  • Loading branch information
bichikim committed Feb 19, 2022
1 parent c7b600a commit dac1767
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/runtime-core/__tests__/debug.spec.ts
Original file line number Diff line number Diff line change
@@ -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('<div>foo</div>')
expect(instance!.setupState).toEqual({
name: 'foo',
})
})
})

0 comments on commit dac1767

Please sign in to comment.