mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
c8b2b28c95
* TODO: fix test case * TODO: 样式、test文件的import * TODO: 伪类不生效 * temp changed * fix: disable eslint * chore: update snapshots * chore: 解决伪类不生效 * chore: update token prop name * TODO: mark FIXME * fix: recover snapshot * fix: recover snapshot again * chore: update snapshot Co-authored-by: Zack Chang <zackchangjx@foxmail.com>
35 lines
1.3 KiB
JavaScript
35 lines
1.3 KiB
JavaScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
// eslint-disable-next-line import/no-named-as-default
|
|
import Spin, { Spin as SpinClass } from '..';
|
|
import { sleep } from '../../../tests/utils';
|
|
|
|
describe('delay spinning', () => {
|
|
it("should render with delay when it's mounted with spinning=true and delay", () => {
|
|
const wrapper = mount(<Spin spinning delay={500} />);
|
|
expect(wrapper.find('.ant-spin').at(0).hasClass('ant-spin-spinning')).toEqual(false);
|
|
});
|
|
|
|
it('should render when delay is init set', async () => {
|
|
const wrapper = mount(<Spin spinning delay={100} />);
|
|
|
|
expect(wrapper.find('.ant-spin').at(0).hasClass('ant-spin-spinning')).toEqual(false);
|
|
|
|
// use await not jest.runAllTimers()
|
|
// because of https://github.com/facebook/jest/issues/3465
|
|
await sleep(500);
|
|
wrapper.update();
|
|
|
|
expect(wrapper.find('.ant-spin').at(0).hasClass('ant-spin-spinning')).toEqual(true);
|
|
});
|
|
|
|
it('should cancel debounce function when unmount', async () => {
|
|
const wrapper = mount(<Spin spinning delay={100} />);
|
|
const spy = jest.spyOn(wrapper.find(SpinClass).instance().updateSpinning, 'cancel');
|
|
expect(wrapper.find(SpinClass).instance().updateSpinning.cancel).toEqual(expect.any(Function));
|
|
expect(spy).not.toHaveBeenCalled();
|
|
wrapper.unmount();
|
|
expect(spy).toHaveBeenCalled();
|
|
});
|
|
});
|