mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 16:06:28 +08:00
chore: update rc-steps and add test case (#38319)
* feat: update rc-steps * feat: update rc-steps * feat: update rc-steps * feat: fix items
This commit is contained in:
parent
f151990700
commit
53c2be01ca
@ -2,7 +2,7 @@ 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 { fireEvent, render, screen } from '../../../tests/utils';
|
||||
import { resetWarned } from '../../_util/warning';
|
||||
|
||||
describe('Steps', () => {
|
||||
@ -33,6 +33,46 @@ describe('Steps', () => {
|
||||
expect(container.firstChild).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('items out of render function', () => {
|
||||
const items = [
|
||||
{
|
||||
title: '已完成',
|
||||
},
|
||||
{
|
||||
title: '进行中',
|
||||
},
|
||||
{
|
||||
title: '待运行',
|
||||
description: 'Hello World!',
|
||||
},
|
||||
{
|
||||
title: '待运行',
|
||||
},
|
||||
];
|
||||
const ControlSteps = () => {
|
||||
const [current, setCurrent] = React.useState(0);
|
||||
return (
|
||||
<Steps
|
||||
current={current}
|
||||
onChange={(val: number) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('Change:', val);
|
||||
setCurrent(val);
|
||||
}}
|
||||
items={items}
|
||||
/>
|
||||
);
|
||||
};
|
||||
const { container } = render(<ControlSteps />);
|
||||
expect(
|
||||
container.querySelectorAll('.ant-steps-item')[1].classList.contains('ant-steps-item-process'),
|
||||
).toBe(false);
|
||||
fireEvent.click(screen.getByText(/进行中/i));
|
||||
expect(
|
||||
container.querySelectorAll('.ant-steps-item')[1].classList.contains('ant-steps-item-process'),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should render correct when use Step', () => {
|
||||
const { container } = render(
|
||||
<Steps>
|
||||
|
@ -145,7 +145,7 @@
|
||||
"rc-segmented": "~2.1.0",
|
||||
"rc-select": "~14.1.13",
|
||||
"rc-slider": "~10.0.0",
|
||||
"rc-steps": "~5.0.0-alpha.0",
|
||||
"rc-steps": "~5.0.0-alpha.2",
|
||||
"rc-switch": "~3.2.0",
|
||||
"rc-table": "~7.26.0",
|
||||
"rc-tabs": "~12.2.0",
|
||||
|
Loading…
Reference in New Issue
Block a user