ant-design/components/spin/__tests__/delay.test.js
afc163 e34e215f5f update debounce when update delay
️ improve getDerivedStateFromProps return value
2019-01-10 21:55:12 +08:00

39 lines
977 B
JavaScript

import React from 'react';
import { mount } from 'enzyme';
import Spin from '..';
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 new Promise(resolve => setTimeout(resolve, 500));
wrapper.update();
expect(
wrapper
.find('.ant-spin')
.at(0)
.hasClass('ant-spin-spinning'),
).toEqual(true);
});
});