2022-09-16 15:52:14 +08:00
|
|
|
import React from 'react';
|
2019-08-26 22:53:20 +08:00
|
|
|
import Steps from '..';
|
|
|
|
import mountTest from '../../../tests/shared/mountTest';
|
2020-01-02 19:10:16 +08:00
|
|
|
import rtlTest from '../../../tests/shared/rtlTest';
|
2022-09-16 15:52:14 +08:00
|
|
|
import { render } from '../../../tests/utils';
|
|
|
|
import { resetWarned } from '../../_util/warning';
|
2019-08-26 22:53:20 +08:00
|
|
|
|
|
|
|
describe('Steps', () => {
|
|
|
|
mountTest(Steps);
|
2020-01-02 19:10:16 +08:00
|
|
|
rtlTest(Steps);
|
2022-09-16 15:52:14 +08:00
|
|
|
|
|
|
|
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();
|
|
|
|
});
|
2019-08-26 22:53:20 +08:00
|
|
|
});
|