mirror of https://github.com/vuejs/core.git
test: add test case
This commit is contained in:
parent
ffbe87e7a3
commit
acb325c13c
|
@ -6,6 +6,7 @@ import {
|
|||
getCurrentInstance,
|
||||
nextTick,
|
||||
onErrorCaptured,
|
||||
onScopeDispose,
|
||||
onWatcherCleanup,
|
||||
reactive,
|
||||
ref,
|
||||
|
@ -1362,6 +1363,32 @@ describe('api: watch', () => {
|
|||
expect(source.mock.calls.some(args => args.includes(instance)))
|
||||
})
|
||||
|
||||
test('this.$watch w/ onScopeDispose', () => {
|
||||
const onCleanup = vi.fn()
|
||||
const toggle = ref(true)
|
||||
|
||||
const Comp = defineComponent({
|
||||
render() {},
|
||||
created(this: any) {
|
||||
this.$watch(
|
||||
() => 1,
|
||||
function () {},
|
||||
)
|
||||
onScopeDispose(onCleanup)
|
||||
},
|
||||
})
|
||||
|
||||
const App = defineComponent({
|
||||
render() {
|
||||
return toggle.value ? h(Comp) : null
|
||||
},
|
||||
})
|
||||
|
||||
const root = nodeOps.createElement('div')
|
||||
createApp(App).mount(root)
|
||||
expect(onCleanup).toBeCalledTimes(0)
|
||||
})
|
||||
|
||||
test('should not leak `this.proxy` to setup()', () => {
|
||||
const source = vi.fn()
|
||||
|
||||
|
|
Loading…
Reference in New Issue