Browse Source

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

pull/35108/head
afc163 3 years ago
committed by GitHub
parent
commit
f1f56e3177
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      components/spin/__tests__/delay.test.js
  2. 6
      components/spin/__tests__/index.test.js
  3. 2
      components/spin/index.tsx

6
components/spin/__tests__/delay.test.js

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

6
components/spin/__tests__/index.test.js

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

2
components/spin/index.tsx

@ -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…
Cancel
Save