mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-17 23:50:52 +08:00

* basic flex * chore: style basic * chore: status style * chore: small size * chore: label vertical * chore: more style * chore: hover disabled * chore: variant * chore: dot variant * chore: max width * chore: hover dot * chore: update style * chore: click style * chore: init percent * chore: pass detail * chore: for progress * chore: clean up * chore: clean up * chore: multiple css var * chore: status text * chore: status use var * chore: fix nest * chore: use svg * chore: type of panel * chore: offset support * chore: inline offset * chore: warning of steps * docs: add semantic preview * chore: semantic transition * chore: hover * chore: adjust style * chore: update semantic preview * chore: fix nav style * chore: patch panel motion * chore: update semantic preview * docs: update config provider doc * chore: fix part ts def * chore: fix test ts * test: update test case * test: coverage * chore: fix lint * test: update test case * test: update snapshot * chore: adjust style * chore: fix rtl * docs: update design * chore: update sctructure * chore: update comment * chore: clean up * chore: clean up * chore: cursor style * chore: coverage * docs: add missing part * chore: order * test: add test case * chore: fix ts * chore: clean up
81 lines
2.4 KiB
TypeScript
81 lines
2.4 KiB
TypeScript
import React from 'react';
|
|
|
|
import Steps from '..';
|
|
import type { StepsProps } from '..';
|
|
import type { GetProp } from '../../_util/type';
|
|
import { render } from '../../../tests/utils';
|
|
|
|
type SemanticName = keyof GetProp<StepsProps, 'classNames'>;
|
|
|
|
describe('Steps.Semantic', () => {
|
|
const renderSteps = (props: Partial<StepsProps>) => (
|
|
<Steps
|
|
items={Array.from({ length: 3 }, (_, index) => ({
|
|
title: `Step ${index + 1}`,
|
|
subTitle: `SubTitle ${index + 1}`,
|
|
description: `Description ${index + 1}`,
|
|
}))}
|
|
{...props}
|
|
/>
|
|
);
|
|
|
|
it('semantic structure', () => {
|
|
const classNames: Record<SemanticName, string> = {
|
|
root: 'custom-root',
|
|
item: 'custom-item',
|
|
itemWrapper: 'custom-item-wrapper',
|
|
itemIcon: 'custom-item-icon',
|
|
itemSection: 'custom-item-section',
|
|
itemHeader: 'custom-item-header',
|
|
itemTitle: 'custom-item-title',
|
|
itemSubtitle: 'custom-item-subtitle',
|
|
itemContent: 'custom-item-content',
|
|
itemRail: 'custom-item-rail',
|
|
};
|
|
|
|
const classNamesTargets: Record<SemanticName, string> = {
|
|
root: 'ant-steps',
|
|
item: 'ant-steps-item',
|
|
itemWrapper: 'ant-steps-item-wrapper',
|
|
itemIcon: 'ant-steps-item-icon',
|
|
itemSection: 'ant-steps-item-section',
|
|
itemHeader: 'ant-steps-item-header',
|
|
itemTitle: 'ant-steps-item-title',
|
|
itemSubtitle: 'ant-steps-item-subtitle',
|
|
itemContent: 'ant-steps-item-content',
|
|
itemRail: 'ant-steps-item-rail',
|
|
};
|
|
|
|
const styles: Record<SemanticName, Record<string, any>> = {
|
|
root: { color: 'red' },
|
|
item: { color: 'blue' },
|
|
itemWrapper: { color: 'green' },
|
|
itemIcon: { color: 'yellow' },
|
|
itemSection: { color: 'purple' },
|
|
itemHeader: { color: 'orange' },
|
|
itemTitle: { color: 'pink' },
|
|
itemSubtitle: { color: 'cyan' },
|
|
itemContent: { color: 'magenta' },
|
|
itemRail: { color: 'lime' },
|
|
};
|
|
|
|
const { container } = render(
|
|
renderSteps({
|
|
classNames,
|
|
styles,
|
|
}),
|
|
);
|
|
|
|
Object.keys(classNames).forEach((key) => {
|
|
const className = classNames[key as SemanticName];
|
|
const oriClassName = classNamesTargets[key as SemanticName];
|
|
const style = styles[key as SemanticName];
|
|
|
|
const element = container.querySelector<HTMLElement>(`.${className}`);
|
|
expect(element).toBeTruthy();
|
|
expect(element).toHaveClass(oriClassName);
|
|
expect(element).toHaveStyle(style);
|
|
});
|
|
});
|
|
});
|