ant-design/components/spin/__tests__/index.test.js
Junbin Huang d78c0f2707
Chore/fix master conflict (#14126)
* adjust table fixed column z-index (#14036)

fix #13930

* 📝 Add instruction for one column without width left in fixed table

* Add full PR template link in template (#14061)

* add full tmpl link

* adjust

* simplify it

* add cn link

* Fix Affix flickering when scrolling

* update

* fix: top border disappeared under some ie9

* fix calendar month range display (#14049)

* Fix tslint warning

* Correct typescript usage (#14074)

* 🐛 Fix steps style under IE9

close #14001

* 🐛 tweak style for not affecting vertical steps

* 📝 enhance upload documentation

* Input.Group with TimePicker disappear icon: https://codepen.io/mraiguo/pen/QzvvvE?editors=0010

* 🐛 Fix disabled button style in DatePicker panel

https://user-images.githubusercontent.com/507615/50693143-17505400-1071-11e9-9114-b150bef8f7f6.png

* 📝 site: fix BackTop been covered by footer

close #14093

* Update PULL_REQUEST_TEMPLATE.md

* Update pr_cn.md

* 🐛 Fix nested Timeline last item missing line (#14110)

close #14108

* init Spin should also support delay trigger (#14105)

fix #14100

* Update table docs

* bugfix

* Format

* update snapshot

* test: fix spin test
2019-01-06 13:25:59 +08:00

80 lines
2.0 KiB
JavaScript

import React from 'react';
import { render, mount } from 'enzyme';
import Spin from '..';
describe('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();
});
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 = mount(<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', () => {
const wrapper = mount(<Spin spinning={false} />);
expect(wrapper.instance().state.spinning).toBe(false);
wrapper.setProps({ spinning: true });
expect(wrapper.instance().state.spinning).toBe(true);
});
});