diff --git a/src/count-down/index.js b/src/count-down/index.js index f60912b1c..5b75b6817 100644 --- a/src/count-down/index.js +++ b/src/count-down/index.js @@ -44,6 +44,10 @@ export default createComponent({ } }, + beforeDestroy() { + this.pause(); + }, + methods: { start() { if (this.counting) { diff --git a/src/count-down/test/index.spec.js b/src/count-down/test/index.spec.js index 1436ee270..bef0f6058 100644 --- a/src/count-down/test/index.spec.js +++ b/src/count-down/test/index.spec.js @@ -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(); +});