2023-05-10 13:42:12 +08:00
|
|
|
import { Tooltip } from 'antd';
|
2023-02-26 10:28:30 +08:00
|
|
|
import React, { useState } from 'react';
|
2022-09-05 19:41:32 +08:00
|
|
|
import type { ProgressProps } from '..';
|
2018-03-11 00:11:52 +08:00
|
|
|
import Progress from '..';
|
2019-08-26 22:53:20 +08:00
|
|
|
import mountTest from '../../../tests/shared/mountTest';
|
2020-01-02 19:10:16 +08:00
|
|
|
import rtlTest from '../../../tests/shared/rtlTest';
|
2023-02-26 10:28:30 +08:00
|
|
|
import { fireEvent, render } from '../../../tests/utils';
|
2022-06-22 14:57:09 +08:00
|
|
|
import { handleGradient, sortGradient } from '../Line';
|
|
|
|
import ProgressSteps from '../Steps';
|
2023-05-10 13:42:12 +08:00
|
|
|
import { ProgressTypes } from '../progress';
|
2018-03-11 00:11:52 +08:00
|
|
|
|
|
|
|
describe('Progress', () => {
|
2019-08-26 22:53:20 +08:00
|
|
|
mountTest(Progress);
|
2020-01-02 19:10:16 +08:00
|
|
|
rtlTest(Progress);
|
2018-04-29 23:01:58 +08:00
|
|
|
it('successPercent should decide the progress status when it exists', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper, rerender } = render(
|
|
|
|
<Progress percent={100} success={{ percent: 50 }} />,
|
|
|
|
);
|
|
|
|
expect(wrapper.querySelectorAll('.ant-progress-status-success')).toHaveLength(0);
|
2018-03-11 00:11:52 +08:00
|
|
|
|
2022-08-05 12:17:05 +08:00
|
|
|
rerender(<Progress percent={50} success={{ percent: 100 }} />);
|
|
|
|
expect(wrapper.querySelectorAll('.ant-progress-status-success')).toHaveLength(1);
|
2019-02-10 23:06:45 +08:00
|
|
|
|
2022-08-05 12:17:05 +08:00
|
|
|
rerender(<Progress percent={100} success={{ percent: 0 }} />);
|
|
|
|
expect(wrapper.querySelectorAll('.ant-progress-status-success')).toHaveLength(0);
|
2018-03-11 00:11:52 +08:00
|
|
|
});
|
2018-04-18 10:45:07 +08:00
|
|
|
|
2018-04-29 23:01:58 +08:00
|
|
|
it('render out-of-range progress', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(<Progress percent={120} />);
|
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2018-04-18 10:45:07 +08:00
|
|
|
});
|
|
|
|
|
2022-10-31 10:23:26 +08:00
|
|
|
it('render strokeWidth of progress', () => {
|
|
|
|
const { container } = render(<Progress type="circle" percent={30} strokeWidth={50} />);
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
2018-04-29 23:01:58 +08:00
|
|
|
it('render out-of-range progress with info', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(<Progress percent={120} showInfo />);
|
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2018-04-18 11:10:32 +08:00
|
|
|
});
|
|
|
|
|
2020-03-22 17:59:43 +08:00
|
|
|
it('render negative progress', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(<Progress percent={-20} />);
|
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2018-04-18 10:45:07 +08:00
|
|
|
});
|
|
|
|
|
2020-03-22 17:59:43 +08:00
|
|
|
it('render negative successPercent', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(<Progress percent={50} success={{ percent: -20 }} />);
|
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2018-04-18 10:45:07 +08:00
|
|
|
});
|
2018-04-29 23:01:58 +08:00
|
|
|
|
|
|
|
it('render format', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(
|
2018-04-29 23:01:58 +08:00
|
|
|
<Progress
|
|
|
|
percent={50}
|
2020-07-01 23:32:22 +08:00
|
|
|
success={{ percent: 10 }}
|
2018-04-29 23:01:58 +08:00
|
|
|
format={(percent, successPercent) => `${percent} ${successPercent}`}
|
2018-12-07 16:17:45 +08:00
|
|
|
/>,
|
2018-04-29 23:01:58 +08:00
|
|
|
);
|
2022-08-05 12:17:05 +08:00
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2018-04-29 23:01:58 +08:00
|
|
|
});
|
2018-10-13 01:19:41 +08:00
|
|
|
|
|
|
|
it('render strokeColor', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper, rerender } = render(
|
|
|
|
<Progress type="circle" percent={50} strokeColor="red" />,
|
|
|
|
);
|
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
|
|
|
rerender(
|
|
|
|
<Progress
|
|
|
|
strokeColor={{
|
|
|
|
from: '#108ee9',
|
|
|
|
to: '#87d068',
|
|
|
|
}}
|
|
|
|
percent={50}
|
|
|
|
type="line"
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
|
|
|
rerender(
|
|
|
|
<Progress
|
|
|
|
strokeColor={{
|
|
|
|
'0%': '#108ee9',
|
|
|
|
'100%': '#87d068',
|
|
|
|
}}
|
|
|
|
percent={50}
|
|
|
|
type="line"
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2018-10-13 01:19:41 +08:00
|
|
|
});
|
2018-12-04 21:42:04 +08:00
|
|
|
|
|
|
|
it('render normal progress', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(<Progress status="normal" />);
|
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2018-12-04 21:42:04 +08:00
|
|
|
});
|
2019-03-24 17:05:24 +08:00
|
|
|
|
2020-02-25 11:11:19 +08:00
|
|
|
it('render trailColor progress', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(<Progress status="normal" trailColor="#ffffff" />);
|
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2020-02-25 11:11:19 +08:00
|
|
|
});
|
|
|
|
|
2020-06-28 22:41:59 +08:00
|
|
|
it('render successColor progress', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(
|
2020-07-01 23:32:22 +08:00
|
|
|
<Progress percent={60} success={{ percent: 30, strokeColor: '#ffffff' }} />,
|
2020-06-28 22:41:59 +08:00
|
|
|
);
|
2022-08-05 12:17:05 +08:00
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2020-06-28 22:41:59 +08:00
|
|
|
});
|
|
|
|
|
2021-07-30 13:17:57 +08:00
|
|
|
it('render successColor progress type="circle"', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(
|
2021-07-30 13:17:57 +08:00
|
|
|
<Progress percent={60} type="circle" success={{ percent: 30, strokeColor: '#ffffff' }} />,
|
|
|
|
);
|
2022-08-05 12:17:05 +08:00
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2021-07-30 13:17:57 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('render successColor progress type="dashboard"', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(
|
2021-07-30 13:17:57 +08:00
|
|
|
<Progress percent={60} type="dashboard" success={{ percent: 30, strokeColor: '#ffffff' }} />,
|
|
|
|
);
|
2022-08-05 12:17:05 +08:00
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2021-07-30 13:17:57 +08:00
|
|
|
});
|
|
|
|
|
2020-03-22 17:59:43 +08:00
|
|
|
it('render dashboard zero gapDegree', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(<Progress type="dashboard" gapDegree={0} />);
|
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2020-03-22 17:59:43 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('render dashboard 295 gapDegree', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(<Progress type="dashboard" gapDegree={295} />);
|
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2020-03-22 17:59:43 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('render dashboard 296 gapDegree', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(<Progress type="dashboard" gapDegree={296} />);
|
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2020-03-22 17:59:43 +08:00
|
|
|
});
|
|
|
|
|
2019-03-24 17:05:24 +08:00
|
|
|
it('get correct line-gradient', () => {
|
|
|
|
expect(handleGradient({ from: 'test', to: 'test' }).backgroundImage).toBe(
|
|
|
|
'linear-gradient(to right, test, test)',
|
|
|
|
);
|
2023-01-11 14:22:48 +08:00
|
|
|
expect(handleGradient({}).backgroundImage).toBe('linear-gradient(to right, #1677FF, #1677FF)');
|
2019-03-24 17:05:24 +08:00
|
|
|
expect(handleGradient({ from: 'test', to: 'test', '0%': 'test' }).backgroundImage).toBe(
|
|
|
|
'linear-gradient(to right, test 0%)',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('sort gradients correctly', () => {
|
|
|
|
expect(sortGradient({ '10%': 'test10', '30%': 'test30', '20%': 'test20' })).toBe(
|
|
|
|
'test10 10%, test20 20%, test30 30%',
|
|
|
|
);
|
2020-02-25 12:21:49 +08:00
|
|
|
expect(sortGradient({ '10%': 'test10', '30%': 'test30', '20%': 'test20', dummy: 'test' })).toBe(
|
|
|
|
'test10 10%, test20 20%, test30 30%',
|
|
|
|
);
|
2019-03-24 17:05:24 +08:00
|
|
|
});
|
2019-04-08 21:43:30 +08:00
|
|
|
|
|
|
|
it('should show success status when percent is 100', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(<Progress percent={100} />);
|
|
|
|
expect(wrapper.querySelectorAll('.ant-progress-status-success')).toHaveLength(1);
|
2019-04-08 21:43:30 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/15950
|
|
|
|
it('should show success status when percent is 100 and status is undefined', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(<Progress percent={100} status={undefined} />);
|
|
|
|
expect(wrapper.querySelectorAll('.ant-progress-status-success')).toHaveLength(1);
|
2019-04-08 22:33:12 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/pull/15951#discussion_r273062969
|
|
|
|
it('should show success status when status is invalid', () => {
|
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
2022-09-05 19:41:32 +08:00
|
|
|
const { container: wrapper } = render(
|
|
|
|
<Progress percent={100} status={'invalid' as ProgressProps['status']} />,
|
|
|
|
);
|
2022-08-05 12:17:05 +08:00
|
|
|
expect(wrapper.querySelectorAll('.ant-progress-status-success')).toHaveLength(1);
|
2019-04-08 22:33:12 +08:00
|
|
|
errorSpy.mockRestore();
|
2019-04-08 21:43:30 +08:00
|
|
|
});
|
2020-05-25 16:27:02 +08:00
|
|
|
|
|
|
|
it('should support steps', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(<Progress steps={3} />);
|
|
|
|
expect(wrapper.firstChild).toMatchSnapshot();
|
2020-05-25 16:27:02 +08:00
|
|
|
});
|
2020-05-29 13:43:53 +08:00
|
|
|
|
2023-02-23 21:56:43 +08:00
|
|
|
it('steps should be changeable', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper, rerender } = render(<Progress steps={5} percent={60} />);
|
|
|
|
expect(wrapper.querySelectorAll('.ant-progress-steps-item-active').length).toBe(3);
|
|
|
|
rerender(<Progress steps={5} percent={40} />);
|
|
|
|
expect(wrapper.querySelectorAll('.ant-progress-steps-item-active').length).toBe(2);
|
2020-05-29 13:43:53 +08:00
|
|
|
});
|
|
|
|
|
2023-02-23 21:56:43 +08:00
|
|
|
it('steps should be changeable when has strokeColor', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper, rerender } = render(
|
|
|
|
<Progress steps={5} percent={60} strokeColor="#1890ff" />,
|
2020-05-29 13:43:53 +08:00
|
|
|
);
|
2022-09-05 19:41:32 +08:00
|
|
|
expect(
|
|
|
|
wrapper.querySelectorAll<HTMLDivElement>('.ant-progress-steps-item')[0].style.backgroundColor,
|
|
|
|
).toBe('rgb(24, 144, 255)');
|
2022-08-05 12:17:05 +08:00
|
|
|
rerender(<Progress steps={5} percent={40} strokeColor="#1890ff" />);
|
2022-09-05 19:41:32 +08:00
|
|
|
expect(
|
|
|
|
wrapper.querySelectorAll<HTMLDivElement>('.ant-progress-steps-item')[2].style.backgroundColor,
|
|
|
|
).toBe('');
|
|
|
|
expect(
|
|
|
|
wrapper.querySelectorAll<HTMLDivElement>('.ant-progress-steps-item')[1].style.backgroundColor,
|
|
|
|
).toBe('rgb(24, 144, 255)');
|
2020-05-29 13:43:53 +08:00
|
|
|
});
|
2020-07-01 23:32:22 +08:00
|
|
|
|
2020-08-22 01:29:48 +08:00
|
|
|
it('steps should support trailColor', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper } = render(<Progress steps={5} percent={20} trailColor="#1890ee" />);
|
2022-09-05 19:41:32 +08:00
|
|
|
expect(
|
|
|
|
wrapper.querySelectorAll<HTMLDivElement>('.ant-progress-steps-item')[1].style.backgroundColor,
|
|
|
|
).toBe('rgb(24, 144, 238)');
|
2020-08-22 01:29:48 +08:00
|
|
|
});
|
|
|
|
|
2020-12-29 12:20:11 +08:00
|
|
|
it('should display correct step', () => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { container: wrapper, rerender } = render(<Progress steps={9} percent={22.22} />);
|
|
|
|
expect(wrapper.querySelectorAll('.ant-progress-steps-item-active').length).toBe(2);
|
|
|
|
rerender(<Progress steps={9} percent={33.33} />);
|
|
|
|
expect(wrapper.querySelectorAll('.ant-progress-steps-item-active').length).toBe(3);
|
|
|
|
rerender(<Progress steps={9} percent={44.44} />);
|
|
|
|
expect(wrapper.querySelectorAll('.ant-progress-steps-item-active').length).toBe(4);
|
2020-12-29 12:20:11 +08:00
|
|
|
});
|
|
|
|
|
2020-08-22 01:29:48 +08:00
|
|
|
it('steps should have default percent 0', () => {
|
2022-09-05 19:41:32 +08:00
|
|
|
const { container } = render(<ProgressSteps steps={0} />);
|
|
|
|
expect(container.firstChild).toMatchSnapshot();
|
2020-08-22 01:29:48 +08:00
|
|
|
});
|
|
|
|
|
2023-02-23 21:56:43 +08:00
|
|
|
it('should warning if use `progress` in success', () => {
|
2020-07-01 23:32:22 +08:00
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
2022-08-05 12:17:05 +08:00
|
|
|
render(<Progress percent={60} success={{ progress: 30 }} />);
|
2020-07-01 23:32:22 +08:00
|
|
|
expect(errorSpy).toHaveBeenCalledWith(
|
|
|
|
'Warning: [antd: Progress] `success.progress` is deprecated. Please use `success.percent` instead.',
|
|
|
|
);
|
2020-08-20 17:15:40 +08:00
|
|
|
});
|
2023-03-01 11:49:42 +08:00
|
|
|
it('should warnning if use `width` prop', () => {
|
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
render(<Progress percent={60} width={100} />);
|
|
|
|
expect(errorSpy).toHaveBeenCalledWith(
|
|
|
|
'Warning: [antd: Progress] `width` is deprecated. Please use `size` instead.',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should warnning if use `strokeWidth` prop in type Line', () => {
|
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
render(<Progress percent={60} strokeWidth={10} />);
|
|
|
|
expect(errorSpy).toHaveBeenCalledWith(
|
|
|
|
'Warning: [antd: Progress] `strokeWidth` is deprecated. Please use `size` instead.',
|
|
|
|
);
|
|
|
|
});
|
2020-07-01 23:32:22 +08:00
|
|
|
|
2023-02-23 21:56:43 +08:00
|
|
|
it('should warning if use `progress` in success in type Circle', () => {
|
2020-07-01 23:32:22 +08:00
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
2022-08-05 12:17:05 +08:00
|
|
|
render(<Progress percent={60} success={{ progress: 30 }} type="circle" />);
|
2020-07-01 23:32:22 +08:00
|
|
|
expect(errorSpy).toHaveBeenCalledWith(
|
|
|
|
'Warning: [antd: Progress] `success.progress` is deprecated. Please use `success.percent` instead.',
|
|
|
|
);
|
2020-08-20 17:15:40 +08:00
|
|
|
});
|
2021-06-05 13:25:19 +08:00
|
|
|
|
2023-03-01 11:49:42 +08:00
|
|
|
it('should warnning if pass number[] into `size` in type Circle', () => {
|
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
render(<Progress size={[60, 20]} type="circle" />);
|
|
|
|
expect(errorSpy).toHaveBeenCalledWith(
|
|
|
|
'Warning: [antd: Progress] Type "circle" and "dashbord" do not accept array as `size`, please use number or preset size instead.',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2023-05-13 16:42:38 +08:00
|
|
|
it('should not warning if not pass the `size` prop in type Circle', () => {
|
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
errorSpy.mockClear();
|
|
|
|
render(<Progress type="circle" />);
|
|
|
|
expect(errorSpy).not.toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
|
2023-03-01 11:49:42 +08:00
|
|
|
it('should warnning if pass number[] into `size` in type dashboard', () => {
|
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
render(<Progress size={[60, 20]} type="dashboard" />);
|
|
|
|
expect(errorSpy).toHaveBeenCalledWith(
|
|
|
|
'Warning: [antd: Progress] Type "circle" and "dashbord" do not accept array as `size`, please use number or preset size instead.',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2023-02-26 10:28:30 +08:00
|
|
|
it('should update the percentage based on the value of percent', () => {
|
2023-02-27 19:33:03 +08:00
|
|
|
const Content: React.FC = () => {
|
|
|
|
const [percent, setPercent] = useState(0);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{ProgressTypes.map((type) => (
|
|
|
|
<Progress key={type} type={type} percent={percent} success={{ percent: 30 }} />
|
|
|
|
))}
|
|
|
|
<button type="button" onClick={() => setPercent(10)}>
|
|
|
|
Change Percent
|
|
|
|
</button>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2023-02-26 10:28:30 +08:00
|
|
|
const { container } = render(<Content />);
|
|
|
|
expect(container.querySelectorAll('[title="0%"]')).toHaveLength(ProgressTypes.length);
|
|
|
|
// Change Percent
|
|
|
|
fireEvent.click(container.querySelectorAll('button')[0]);
|
|
|
|
expect(container.querySelectorAll('[title="10%"]')).toHaveLength(ProgressTypes.length);
|
|
|
|
});
|
|
|
|
|
2021-06-05 13:25:19 +08:00
|
|
|
describe('github issues', () => {
|
2023-01-29 11:50:30 +08:00
|
|
|
// https://github.com/ant-design/ant-design/issues/30685
|
|
|
|
it('Rendered more hooks than during the previous render', () => {
|
2021-06-05 13:25:19 +08:00
|
|
|
expect(() => {
|
2022-08-05 12:17:05 +08:00
|
|
|
const { rerender } = render(
|
|
|
|
<Progress percent={60} success={{ percent: 0 }} type="circle" />,
|
|
|
|
);
|
|
|
|
rerender(<Progress percent={60} success={{ percent: 10 }} type="circle" />);
|
2021-06-05 13:25:19 +08:00
|
|
|
}).not.toThrow();
|
|
|
|
});
|
2023-01-29 11:50:30 +08:00
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/40377
|
|
|
|
it('should not throw error when percent is null', () => {
|
|
|
|
expect(() => {
|
|
|
|
render(<Progress percent={null as unknown as number} />);
|
|
|
|
}).not.toThrow();
|
|
|
|
});
|
2021-06-05 13:25:19 +08:00
|
|
|
});
|
2023-03-01 11:49:42 +08:00
|
|
|
|
|
|
|
describe('progress size', () => {
|
|
|
|
const App = (props: { size: ProgressProps['size'] }) => (
|
|
|
|
<>
|
|
|
|
<Progress size={props.size} />
|
|
|
|
<Progress size={props.size} steps={3} />
|
|
|
|
<Progress type="circle" size={props.size} />
|
|
|
|
<Progress type="dashboard" size={props.size} />
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
|
|
|
|
const { container, rerender } = render(<App size={30} />);
|
|
|
|
expect(container.querySelector('.ant-progress-line .ant-progress-outer')).toHaveStyle({
|
|
|
|
width: '30px',
|
|
|
|
});
|
|
|
|
expect(container.querySelector('.ant-progress-steps .ant-progress-steps-item')).toHaveStyle({
|
|
|
|
width: '30px',
|
|
|
|
height: '30px',
|
|
|
|
});
|
|
|
|
expect(container.querySelectorAll('.ant-progress-circle .ant-progress-inner')[0]).toHaveStyle({
|
|
|
|
width: '30px',
|
|
|
|
height: '30px',
|
|
|
|
});
|
|
|
|
expect(container.querySelectorAll('.ant-progress-circle .ant-progress-inner')[1]).toHaveStyle({
|
|
|
|
width: '30px',
|
|
|
|
height: '30px',
|
|
|
|
});
|
|
|
|
|
|
|
|
rerender(<App size={[60, 20]} />);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-progress-line .ant-progress-outer')).toHaveStyle({
|
|
|
|
width: '60px',
|
|
|
|
height: '20px',
|
|
|
|
});
|
|
|
|
expect(container.querySelector('.ant-progress-steps .ant-progress-steps-item')).toHaveStyle({
|
|
|
|
width: '60px',
|
|
|
|
height: '20px',
|
|
|
|
});
|
|
|
|
expect(container.querySelectorAll('.ant-progress-circle .ant-progress-inner')[0]).toHaveStyle({
|
|
|
|
width: '60px',
|
|
|
|
height: '60px',
|
|
|
|
});
|
|
|
|
expect(container.querySelectorAll('.ant-progress-circle .ant-progress-inner')[1]).toHaveStyle({
|
|
|
|
width: '60px',
|
|
|
|
height: '60px',
|
|
|
|
});
|
|
|
|
});
|
2023-05-10 13:42:12 +08:00
|
|
|
|
|
|
|
it('no strict warning', () => {
|
|
|
|
const errSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
|
|
const { rerender } = render(
|
|
|
|
<Tooltip title="当前已使用60%">
|
|
|
|
<Progress percent={60} type="circle" />
|
|
|
|
</Tooltip>,
|
|
|
|
);
|
|
|
|
rerender(
|
|
|
|
<Tooltip title="当前已使用60%">
|
|
|
|
<Progress percent={60} type="circle" />
|
|
|
|
</Tooltip>,
|
|
|
|
);
|
|
|
|
expect(errSpy).not.toHaveBeenCalledWith(
|
|
|
|
expect.stringContaining('findDOMNode is deprecated in StrictMode'),
|
|
|
|
);
|
|
|
|
errSpy.mockRestore();
|
|
|
|
});
|
2018-03-11 00:11:52 +08:00
|
|
|
});
|