mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
fix(CountDown): should clear timer when destroyed (#4918)
This commit is contained in:
parent
577174c7f8
commit
e0e597d164
@ -44,6 +44,10 @@ export default createComponent({
|
||||
}
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
this.pause();
|
||||
},
|
||||
|
||||
methods: {
|
||||
start() {
|
||||
if (this.counting) {
|
||||
|
@ -149,3 +149,16 @@ test('incomplate format prop', () => {
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('pause when destroyed', async () => {
|
||||
const pause = jest.fn();
|
||||
const wrapper = mount(CountDown, {
|
||||
mocks: {
|
||||
pause
|
||||
}
|
||||
});
|
||||
|
||||
wrapper.destroy();
|
||||
|
||||
expect(wrapper.vm.counting).toBeFalsy();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user