mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 20:19:44 +08:00
chore: fix Spin eslint errors in test (#35105)
This commit is contained in:
parent
e8991979fd
commit
f1f56e3177
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
// eslint-disable-next-line import/no-named-as-default
|
||||
import Spin, { Spin as SpinClass } from '..';
|
||||
import Spin from '..';
|
||||
import { sleep } from '../../../tests/utils';
|
||||
|
||||
describe('delay spinning', () => {
|
||||
@ -25,8 +25,8 @@ describe('delay spinning', () => {
|
||||
|
||||
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));
|
||||
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();
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { render, mount } from 'enzyme';
|
||||
// eslint-disable-next-line import/no-named-as-default
|
||||
import Spin, { Spin as SpinClass } from '..';
|
||||
import Spin from '..';
|
||||
import mountTest from '../../../tests/shared/mountTest';
|
||||
import rtlTest from '../../../tests/shared/rtlTest';
|
||||
|
||||
@ -27,9 +27,9 @@ describe('Spin', () => {
|
||||
|
||||
it('should be controlled by spinning', () => {
|
||||
const wrapper = mount(<Spin spinning={false} />);
|
||||
expect(wrapper.find(SpinClass).instance().state.spinning).toBe(false);
|
||||
expect(wrapper.find(Spin).instance().state.spinning).toBe(false);
|
||||
wrapper.setProps({ spinning: true });
|
||||
expect(wrapper.find(SpinClass).instance().state.spinning).toBe(true);
|
||||
expect(wrapper.find(Spin).instance().state.spinning).toBe(true);
|
||||
});
|
||||
|
||||
it('if indicator set null should not be render default indicator', () => {
|
||||
|
@ -76,7 +76,7 @@ function shouldDelay(spinning?: boolean, delay?: number): boolean {
|
||||
return !!spinning && !!delay && !isNaN(Number(delay));
|
||||
}
|
||||
|
||||
export class Spin extends React.Component<SpinClassProps, SpinState> {
|
||||
class Spin extends React.Component<SpinClassProps, SpinState> {
|
||||
static defaultProps = {
|
||||
spinning: true,
|
||||
size: 'default' as SpinSize,
|
||||
|
Loading…
Reference in New Issue
Block a user