chore: fix Spin eslint errors in test (#35105)

This commit is contained in:
afc163 2022-04-19 23:37:49 +08:00 committed by GitHub
parent e8991979fd
commit f1f56e3177
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 7 deletions

View File

@ -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();

View File

@ -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', () => {

View File

@ -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,