mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-02 15:59:38 +08:00
20d5502193
* chore(deps-dev): bump eslint-config-airbnb from 18.2.1 to 19.0.0 Bumps [eslint-config-airbnb](https://github.com/airbnb/javascript) from 18.2.1 to 19.0.0. - [Release notes](https://github.com/airbnb/javascript/releases) - [Commits](https://github.com/airbnb/javascript/compare/eslint-config-airbnb-v18.2.1...eslint-config-airbnb-v19.0.0) --- updated-dependencies: - dependency-name: eslint-config-airbnb dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * chore: code style * memoize-one * add comment * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * improve useMemo deps Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: afc163 <afc163@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.instance().updateSpinning, 'cancel');
|
|
expect(wrapper.instance().updateSpinning.cancel).toEqual(expect.any(Function));
|
|
expect(spy).not.toHaveBeenCalled();
|
|
wrapper.unmount();
|
|
expect(spy).toHaveBeenCalled();
|
|
});
|
|
});
|