Add test case for unmounting spin

This commit is contained in:
afc163 2019-01-07 14:21:57 +08:00 committed by 偏右
parent e34e215f5f
commit 1e62802d58

View File

@ -35,4 +35,13 @@ describe('delay spinning', () => {
.hasClass('ant-spin-spinning'), .hasClass('ant-spin-spinning'),
).toEqual(true); ).toEqual(true);
}); });
it('should cancel debounce function when unmount', async () => {
const wrapper = mount(<Spin spinning delay={100} />);
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();
});
}); });