Skip to content

Commit e40e2c9

Browse files
committed
test: add test case
1 parent cae5fc3 commit e40e2c9

File tree

4 files changed

+25
-4
lines changed

4 files changed

+25
-4
lines changed

src/Step.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export default function Step(props: StepProps) {
139139
iconNode = iconRender(iconNode, {
140140
...renderInfo,
141141
components: {
142-
icon: StepIcon,
142+
Icon: StepIcon,
143143
},
144144
}) as React.ReactElement;
145145
}

src/StepIcon.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import pickAttrs from '@rc-component/util/lib/pickAttrs';
66
export type StepIconProps = React.HTMLAttributes<HTMLDivElement>;
77

88
const StepIcon = React.forwardRef<HTMLDivElement, StepIconProps>((props, ref) => {
9-
const { className, style, ...restProps } = props;
9+
const { className, style, children, ...restProps } = props;
1010
const { prefixCls, classNames, styles } = React.useContext(StepsContext);
1111

1212
const itemCls = `${prefixCls}-item`;
@@ -20,7 +20,9 @@ const StepIcon = React.forwardRef<HTMLDivElement, StepIconProps>((props, ref) =>
2020
...styles.itemIcon,
2121
...style,
2222
}}
23-
/>
23+
>
24+
{children}
25+
</div>
2426
);
2527
});
2628

src/Steps.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export interface StepsProps {
7373
originNode: React.ReactElement,
7474
info: RenderInfo & {
7575
components: {
76-
icon: typeof StepIcon;
76+
Icon: typeof StepIcon;
7777
};
7878
},
7979
) => React.ReactNode;

tests/index.test.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,4 +344,23 @@ describe('Steps', () => {
344344
expect(container.querySelector('.rc-steps-item')).toBeTruthy();
345345
expect(container.querySelector('.rc-steps-item > .bamboo')).toBeTruthy();
346346
});
347+
348+
it('iconRender', () => {
349+
const { container } = render(
350+
<Steps
351+
items={[
352+
{
353+
title: 'test',
354+
},
355+
]}
356+
iconRender={(_, { components: { Icon } }) => {
357+
return <Icon className="bamboo">little</Icon>;
358+
}}
359+
/>,
360+
);
361+
362+
const iconEle = container.querySelector('.rc-steps-item-icon')!;
363+
expect(iconEle).toHaveClass('bamboo');
364+
expect(iconEle.textContent).toBe('little');
365+
});
347366
});

0 commit comments

Comments
 (0)