Skip to content

Commit a8847f0

Browse files
committed
test: add test case
1 parent 347bfac commit a8847f0

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

src/Circle/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ const Circle: React.FC<ProgressProps> = (props) => {
102102
radius={radius}
103103
prefixCls={prefixCls}
104104
gradientId={gradientId}
105+
className={classNames.track}
105106
style={{ ...circleStyleForStack, ...indeterminateStyleProps, ...styles.track }}
106107
strokeLinecap={mergedStrokeLinecap}
107108
strokeWidth={strokeWidth}
@@ -150,7 +151,7 @@ const Circle: React.FC<ProgressProps> = (props) => {
150151
return (
151152
<circle
152153
key={index}
153-
className={cls(`${prefixCls}-circle-path`, className)}
154+
className={cls(`${prefixCls}-circle-path`, classNames.track)}
154155
r={radius}
155156
cx={halfSize}
156157
cy={halfSize}

tests/semantic.spec.tsx

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import { Circle, type ProgressProps } from '../src';
4+
5+
describe('Semantic', () => {
6+
describe('Circle', () => {
7+
function test(
8+
name: string,
9+
props: Partial<ProgressProps> = {},
10+
postCallback?: (cotainer: HTMLElement) => void,
11+
) {
12+
it(name, () => {
13+
const classNames: ProgressProps['classNames'] = {
14+
root: 'my-root',
15+
rail: 'my-rail',
16+
track: 'my-track',
17+
};
18+
const styles = {
19+
root: { background: 'red' },
20+
rail: { background: 'blue' },
21+
track: { background: 'green' },
22+
};
23+
24+
const { container } = render(
25+
<Circle percent={50} classNames={classNames} styles={styles} {...props} />,
26+
);
27+
28+
expect(container.querySelector('.rc-progress-circle')).toHaveClass(classNames.root);
29+
expect(container.querySelector('.rc-progress-circle-trail')).toHaveClass(classNames.rail);
30+
expect(container.querySelector('.rc-progress-circle-path')).toHaveClass(classNames.track);
31+
32+
expect(container.querySelector('.my-root')).toHaveStyle(styles.root);
33+
expect(container.querySelector('.my-rail')).toHaveStyle(styles.rail);
34+
expect(container.querySelector('.my-track')).toHaveStyle(styles.track);
35+
36+
postCallback?.(container);
37+
});
38+
}
39+
40+
test('basic');
41+
42+
test(
43+
'gradient',
44+
{
45+
strokeColor: {
46+
'0%': '#f00',
47+
'100%': '#0f0',
48+
},
49+
},
50+
(container) => {
51+
expect(container.querySelector('foreignObject')).toBeTruthy();
52+
},
53+
);
54+
});
55+
});

0 commit comments

Comments
 (0)