Skip to content

Commit 4eaff71

Browse files
committed
test: add assertions for cleanup scope length in templateRef tests
1 parent 3e68a1b commit 4eaff71

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

packages/runtime-vapor/__tests__/dom/templateRef.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,16 +779,19 @@ describe('api: template ref', () => {
779779

780780
expect(fn1).toHaveBeenCalledTimes(1)
781781
expect(fn2).toHaveBeenCalledTimes(0)
782+
expect(app._instance!.scope.cleanups.length).toBe(1)
782783

783784
toggle.value = false
784785
await nextTick()
785786
expect(fn1).toHaveBeenCalledTimes(1)
786787
expect(fn2).toHaveBeenCalledTimes(1)
788+
expect(app._instance!.scope.cleanups.length).toBe(1)
787789

788790
toggle.value = true
789791
await nextTick()
790792
expect(fn1).toHaveBeenCalledTimes(2)
791793
expect(fn2).toHaveBeenCalledTimes(1)
794+
expect(app._instance!.scope.cleanups.length).toBe(1)
792795

793796
app.unmount()
794797
await nextTick()
@@ -823,11 +826,13 @@ describe('api: template ref', () => {
823826

824827
expect(el1.value).toBe(host.children[0])
825828
expect(el2.value).toBe(null)
829+
expect(app._instance!.scope.cleanups.length).toBe(1)
826830

827831
toggle.value = false
828832
await nextTick()
829833
expect(el1.value).toBe(null)
830834
expect(el2.value).toBe(host.children[0])
835+
expect(app._instance!.scope.cleanups.length).toBe(1)
831836

832837
app.unmount()
833838
await nextTick()

0 commit comments

Comments
 (0)