Skip to content

Commit 4239195

Browse files
committed
fix: extra space, type and coverage
1 parent cc2fd04 commit 4239195

File tree

4 files changed

+60
-26
lines changed

4 files changed

+60
-26
lines changed

src/utils/getIndeterminateCircle.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export default ({ id, loading }: IndeterminateOption) => {
2323
indeterminateStyleAnimation: (
2424
<style>
2525
{`@keyframes ${animationName} {
26-
0 % { transform: rotate(0deg);}
26+
0% { transform: rotate(0deg);}
2727
100% {transform: rotate(360deg);}
2828
}`}
2929
</style>

src/utils/getIndeterminateLine.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import type { StrokeLinecapType } from '@/interface';
12
import React from 'react';
23

34
interface IndeterminateOption {
45
id: string;
56
loading: boolean;
67
percent: number;
7-
strokeLinecap: string;
8+
strokeLinecap: StrokeLinecapType;
89
strokeWidth: number;
910
}
1011

tests/indeterminate.spec.tsx

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import React from 'react';
2+
import { Circle, Line } from '../src';
3+
import { render, waitFor } from '@testing-library/react';
4+
5+
describe('(Circle | Line).indeterminate', () => {
6+
describe('Line', () => {
7+
it('should render indeterminate style', () => {
8+
const { container, rerender } = render(<Line loading />);
9+
const line: HTMLElement = container.querySelector('.rc-progress-line-path');
10+
11+
expect(line.style.animation).toContain('indeterminate-animate');
12+
13+
rerender(<Line />);
14+
15+
expect(line.style.animation).not.toContain('indeterminate-animate');
16+
});
17+
18+
it('should render indeterminate with percent and rerennder without it', () => {
19+
const { container, rerender } = render(<Line percent={20} loading />);
20+
const line: HTMLElement = container.querySelector('.rc-progress-line-path');
21+
22+
expect(line.style.animation).toContain('indeterminate-animate');
23+
expect(line.style.strokeDasharray).toEqual('20 100');
24+
25+
rerender(<Line percent={20} />);
26+
27+
expect(line.style.animation).not.toContain('indeterminate-animate');
28+
expect(line.style.strokeDasharray).not.toEqual('20 100');
29+
});
30+
});
31+
32+
describe('Circle', () => {
33+
it('should render indeterminate style', () => {
34+
const { container, rerender } = render(<Circle loading />);
35+
const circle: HTMLElement = container.querySelector('.rc-progress-circle-path');
36+
37+
expect(circle.style.animation).toContain('indeterminate-animate');
38+
39+
rerender(<Circle />);
40+
41+
expect(circle.style.animation).not.toContain('indeterminate-animate');
42+
});
43+
44+
it('should rerender indeterminate with percent Circle', () => {
45+
const { container, rerender } = render(<Circle percent={20} loading />);
46+
const circle: HTMLElement = container.querySelector('.rc-progress-circle-path');
47+
48+
expect(circle.style.animation).toContain('indeterminate-animate');
49+
expect(circle.style.transform).toEqual('rotate(0deg)');
50+
51+
rerender(<Circle percent={20} />);
52+
53+
expect(circle.style.animation).not.toContain('indeterminate-animate');
54+
expect(circle.style.transform).not.toEqual('rotate(0deg)');
55+
});
56+
});
57+
});

tests/index.spec.js

-24
Original file line numberDiff line numberDiff line change
@@ -243,28 +243,4 @@ describe('Progress', () => {
243243
expect(circle.find(Circle).props().percent).toEqual([20, 20, 20, 20]);
244244
circle.unmount();
245245
});
246-
247-
it('should support indeterminate mode', () => {
248-
const Loading = () => {
249-
return (
250-
<>
251-
<Circle loading />
252-
<Line loading />
253-
</>
254-
);
255-
};
256-
257-
const wrapper = mount(<Loading />);
258-
const circle = wrapper.find(Circle);
259-
const line = wrapper.find(Line);
260-
expect(circle.find('style')).toBeDefined();
261-
expect(circle.find('.rc-progress-circle-path').at(0).getDOMNode().style.animation).toContain(
262-
'indeterminate-animate',
263-
);
264-
expect(line.find('style')).toBeDefined();
265-
expect(line.find('.rc-progress-line-path').at(0).getDOMNode().style.animation).toContain(
266-
'indeterminate-animate',
267-
);
268-
wrapper.unmount();
269-
});
270246
});

0 commit comments

Comments
 (0)