Skip to content

Commit a17e424

Browse files
committed
test(back-top): improve test coverage
1 parent 4e2707b commit a17e424

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

packages/varlet-ui/src/back-top/__tests__/index.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,21 @@ describe('test backTop events', () => {
8383
wrapper.unmount()
8484
})
8585
})
86+
87+
test('backTop unmount guard when scroller missing', async () => {
88+
vi.resetModules()
89+
vi.doMock('@varlet/use', async (importOriginal) => {
90+
const actual = await importOriginal()
91+
return {
92+
...actual,
93+
onSmartUnmounted: (hook) => hook(),
94+
}
95+
})
96+
97+
const { default: MockBackTop } = await import('../BackTop')
98+
const wrapper = mount(MockBackTop)
99+
100+
wrapper.unmount()
101+
102+
vi.doUnmock('@varlet/use')
103+
})

0 commit comments

Comments
 (0)