diff --git a/components/progress/__tests__/index.test.tsx b/components/progress/__tests__/index.test.tsx
index ef373d634f..273173ffa6 100644
--- a/components/progress/__tests__/index.test.tsx
+++ b/components/progress/__tests__/index.test.tsx
@@ -1,16 +1,32 @@
-import React from 'react';
+import React, { useState } from 'react';
import type { ProgressProps } from '..';
import Progress from '..';
import mountTest from '../../../tests/shared/mountTest';
import rtlTest from '../../../tests/shared/rtlTest';
-import { render } from '../../../tests/utils';
+import { fireEvent, render } from '../../../tests/utils';
import { handleGradient, sortGradient } from '../Line';
+import { ProgressTypes } from '../progress';
import ProgressSteps from '../Steps';
describe('Progress', () => {
mountTest(Progress);
rtlTest(Progress);
+ const Content = () => {
+ const [percent, setPercent] = useState(0);
+
+ return (
+ <>
+ {ProgressTypes.map((type) => (
+
+ ))}
+
+ >
+ );
+ };
+
it('successPercent should decide the progress status when it exists', () => {
const { container: wrapper, rerender } = render(
,
@@ -240,6 +256,14 @@ describe('Progress', () => {
);
});
+ it('should update the percentage based on the value of percent', () => {
+ const { container } = render();
+ expect(container.querySelectorAll('[title="0%"]')).toHaveLength(ProgressTypes.length);
+ // Change Percent
+ fireEvent.click(container.querySelectorAll('button')[0]);
+ expect(container.querySelectorAll('[title="10%"]')).toHaveLength(ProgressTypes.length);
+ });
+
describe('github issues', () => {
// https://github.com/ant-design/ant-design/issues/30685
it('Rendered more hooks than during the previous render', () => {
diff --git a/components/progress/progress.tsx b/components/progress/progress.tsx
index 566416678b..aed948b402 100644
--- a/components/progress/progress.tsx
+++ b/components/progress/progress.tsx
@@ -14,7 +14,7 @@ import Steps from './Steps';
import useStyle from './style';
import { getSuccessPercent, validProgress } from './utils';
-const ProgressTypes = ['line', 'circle', 'dashboard'] as const;
+export const ProgressTypes = ['line', 'circle', 'dashboard'] as const;
export type ProgressType = typeof ProgressTypes[number];
const ProgressStatuses = ['normal', 'exception', 'active', 'success'] as const;
export type ProgressSize = 'default' | 'small';
@@ -110,7 +110,7 @@ const Progress: React.FC = (props) => {
{text}
);
- }, [showInfo, percentNumber, progressStatus, type, prefixCls, format]);
+ }, [showInfo, percent, percentNumber, progressStatus, type, prefixCls, format]);
warning(
!('successPercent' in props),