mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-11-30 11:08:45 +08:00
parent
059670a09e
commit
b129e05630
@ -29,14 +29,45 @@ describe('Spin', () => {
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should render with delay when it's mounted with spinning=true and delay", () => {
|
||||
const wrapper = shallow(<Spin spinning delay={500} />);
|
||||
expect(
|
||||
wrapper
|
||||
.find('.ant-spin')
|
||||
.at(0)
|
||||
.hasClass('ant-spin-spinning'),
|
||||
).toEqual(false);
|
||||
describe('delay spinning', () => {
|
||||
beforeAll(() => {
|
||||
jest.useFakeTimers();
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
it("should render with delay when it's mounted with spinning=true and delay", () => {
|
||||
const wrapper = shallow(<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', () => {
|
||||
const wrapper = mount(<Spin spinning delay={100} />);
|
||||
|
||||
expect(
|
||||
wrapper
|
||||
.find('.ant-spin')
|
||||
.at(0)
|
||||
.hasClass('ant-spin-spinning'),
|
||||
).toEqual(false);
|
||||
|
||||
jest.runAllTimers();
|
||||
wrapper.update();
|
||||
|
||||
expect(
|
||||
wrapper
|
||||
.find('.ant-spin')
|
||||
.at(0)
|
||||
.hasClass('ant-spin-spinning'),
|
||||
).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should be controlled by spinning', () => {
|
||||
|
@ -94,6 +94,10 @@ class Spin extends React.Component<SpinProps, SpinState> {
|
||||
return !!(this.props && this.props.children);
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.componentDidUpdate();
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this.debounceTimeout) {
|
||||
clearTimeout(this.debounceTimeout);
|
||||
|
Loading…
Reference in New Issue
Block a user