mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
65f067eb13
* feat: support items * feat: update demo * test: update package * test: update use type * test: update for test * test: update for lint * feat: update doc * test: update for lint * test: update for lint * test: update for lint * test: add deprecated dome * test: add deprecated dome * doc: update doc * feat: update package * test: add test case
70 lines
1.9 KiB
TypeScript
70 lines
1.9 KiB
TypeScript
import React from 'react';
|
|
import Steps from '..';
|
|
import mountTest from '../../../tests/shared/mountTest';
|
|
import rtlTest from '../../../tests/shared/rtlTest';
|
|
import { render } from '../../../tests/utils';
|
|
import { resetWarned } from '../../_util/warning';
|
|
|
|
describe('Steps', () => {
|
|
mountTest(Steps);
|
|
rtlTest(Steps);
|
|
|
|
const description = 'This is a description.';
|
|
it('should render correct', () => {
|
|
const { container } = render(
|
|
<Steps
|
|
items={[
|
|
{
|
|
title: 'Finished',
|
|
description,
|
|
},
|
|
{
|
|
title: 'In Progress',
|
|
description,
|
|
subTitle: 'Left 00:00:08',
|
|
},
|
|
{
|
|
title: 'Waiting',
|
|
description,
|
|
},
|
|
]}
|
|
/>,
|
|
);
|
|
expect(container.firstChild).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render correct when use Step', () => {
|
|
const { container } = render(
|
|
<Steps>
|
|
<Steps.Step title="Finished" description={description} />
|
|
<Steps.Step title="In Progress" description={description} subTitle="Left 00:00:08" />
|
|
<Steps.Step title="Waiting" description={description} />
|
|
</Steps>,
|
|
);
|
|
expect(container.firstChild).toMatchSnapshot();
|
|
});
|
|
|
|
it('should render correct when use null', () => {
|
|
const { container } = render(<Steps>null</Steps>);
|
|
expect(container.firstChild).toMatchSnapshot();
|
|
});
|
|
|
|
it('deprecated warning', () => {
|
|
resetWarned();
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
const { container } = render(
|
|
<Steps>
|
|
<Steps.Step title="Finished" description={description} />
|
|
</Steps>,
|
|
);
|
|
|
|
expect(container.querySelectorAll('.ant-steps-item')).toHaveLength(1);
|
|
|
|
expect(errorSpy).toHaveBeenCalledWith(
|
|
'Warning: [antd: Steps] Step is deprecated. Please use `items` directly.',
|
|
);
|
|
errorSpy.mockRestore();
|
|
});
|
|
});
|