From 1e62802d588c84e02fa9c9538f4ac84486512127 Mon Sep 17 00:00:00 2001 From: afc163 Date: Mon, 7 Jan 2019 14:21:57 +0800 Subject: [PATCH] :white_check_mark: Add test case for unmounting spin --- components/spin/__tests__/delay.test.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/spin/__tests__/delay.test.js b/components/spin/__tests__/delay.test.js index d9185323b4..0c05d0a1fc 100644 --- a/components/spin/__tests__/delay.test.js +++ b/components/spin/__tests__/delay.test.js @@ -35,4 +35,13 @@ describe('delay spinning', () => { .hasClass('ant-spin-spinning'), ).toEqual(true); }); + + it('should cancel debounce function when unmount', async () => { + const wrapper = mount(); + const spy = jest.spyOn(wrapper.instance().updateSpinning, 'cancel'); + expect(wrapper.instance().updateSpinning.cancel).toEqual(expect.any(Function)); + expect(spy).not.toHaveBeenCalled(); + wrapper.unmount(); + expect(spy).toHaveBeenCalled(); + }); });