mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-30 06:09:34 +08:00
30ac6bd4e4
* test: React StrictMode * test: fix Spin test * chore: wrapper enzyme * test: fix setState * test: more test cover * test: more test cover * test: more test cover * test: more test cover * test: more test cover * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: more test case * test: disable part of it * test: fix test & add placeholder * test: Use orign enzyme mount Co-authored-by: zombiej <smith3816@gmail.com>
34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
import React from 'react';
|
|
import { mount } from 'enzyme';
|
|
import Spin 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(Spin).instance().updateSpinning, 'cancel');
|
|
expect(wrapper.find(Spin).instance().updateSpinning.cancel).toEqual(expect.any(Function));
|
|
expect(spy).not.toHaveBeenCalled();
|
|
wrapper.unmount();
|
|
expect(spy).toHaveBeenCalled();
|
|
});
|
|
});
|