mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-18 19:39:51 +08:00
775d1800bb
* chore(deps-dev): bump eslint-config-prettier from 6.15.0 to 7.0.0 Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 6.15.0 to 7.0.0. - [Release notes](https://github.com/prettier/eslint-config-prettier/releases) - [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/eslint-config-prettier/compare/v6.15.0...v7.0.0) Signed-off-by: dependabot[bot] <support@github.com> * chore: fix eslint style * chore: prettier code style Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: afc163 <afc163@gmail.com>
51 lines
1.7 KiB
JavaScript
51 lines
1.7 KiB
JavaScript
import React from 'react';
|
|
import { render, mount } from 'enzyme';
|
|
import Spin from '..';
|
|
import mountTest from '../../../tests/shared/mountTest';
|
|
import rtlTest from '../../../tests/shared/rtlTest';
|
|
|
|
describe('Spin', () => {
|
|
mountTest(Spin);
|
|
rtlTest(Spin);
|
|
|
|
it('should only affect the spin element when set style to a nested <Spin>xx</Spin>', () => {
|
|
const wrapper = mount(
|
|
<Spin style={{ background: 'red' }}>
|
|
<div>content</div>
|
|
</Spin>,
|
|
);
|
|
expect(wrapper.find('.ant-spin-nested-loading').at(0).prop('style')).toBeFalsy();
|
|
expect(wrapper.find('.ant-spin').at(0).prop('style').background).toBe('red');
|
|
});
|
|
|
|
it("should render custom indicator when it's set", () => {
|
|
const customIndicator = <div className="custom-indicator" />;
|
|
const wrapper = render(<Spin indicator={customIndicator} />);
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
|
|
it('should be controlled by spinning', () => {
|
|
const wrapper = mount(<Spin spinning={false} />);
|
|
expect(wrapper.instance().state.spinning).toBe(false);
|
|
wrapper.setProps({ spinning: true });
|
|
expect(wrapper.instance().state.spinning).toBe(true);
|
|
});
|
|
|
|
it('if indicator set null should not be render default indicator', () => {
|
|
const wrapper = mount(<Spin indicator={null} />);
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
|
|
it('should support static method Spin.setDefaultIndicator', () => {
|
|
Spin.setDefaultIndicator(<em className="custom-spinner" />);
|
|
const wrapper = mount(<Spin />);
|
|
expect(wrapper).toMatchSnapshot();
|
|
Spin.setDefaultIndicator(null);
|
|
});
|
|
|
|
it('should render 0', () => {
|
|
const wrapper = mount(<Spin>{0}</Spin>);
|
|
expect(wrapper.find('.ant-spin-container').at(0).text()).toBe('0');
|
|
});
|
|
});
|