2023-06-19 19:30:16 +08:00
|
|
|
import React from 'react';
|
2023-09-03 10:20:24 +08:00
|
|
|
|
2023-06-19 19:30:16 +08:00
|
|
|
import ConfigProvider from '..';
|
2023-07-03 20:37:11 +08:00
|
|
|
import { fireEvent, render } from '../../../tests/utils';
|
2023-07-06 09:33:54 +08:00
|
|
|
import Alert from '../../alert';
|
2023-06-26 17:09:55 +08:00
|
|
|
import Anchor from '../../anchor';
|
2023-07-03 10:27:31 +08:00
|
|
|
import Avatar from '../../avatar';
|
2023-06-29 16:43:11 +08:00
|
|
|
import Badge from '../../badge';
|
2023-06-25 18:28:57 +08:00
|
|
|
import Breadcrumb from '../../breadcrumb';
|
2023-07-06 09:38:21 +08:00
|
|
|
import Calendar from '../../calendar';
|
2023-07-03 10:25:55 +08:00
|
|
|
import Card from '../../card';
|
2023-07-07 09:30:37 +08:00
|
|
|
import Carousel from '../../carousel';
|
2023-06-27 17:13:27 +08:00
|
|
|
import Cascader from '../../cascader';
|
2023-06-26 11:42:46 +08:00
|
|
|
import Checkbox from '../../checkbox';
|
2023-07-06 09:45:25 +08:00
|
|
|
import Collapse from '../../collapse';
|
2023-07-04 11:23:58 +08:00
|
|
|
import ColorPicker from '../../color-picker';
|
2023-07-07 19:02:55 +08:00
|
|
|
import DatePicker from '../../date-picker';
|
2023-06-26 14:38:02 +08:00
|
|
|
import Descriptions from '../../descriptions';
|
2023-06-19 19:30:16 +08:00
|
|
|
import Divider from '../../divider';
|
2023-07-06 10:42:13 +08:00
|
|
|
import Drawer from '../../drawer';
|
2023-11-02 00:48:26 +08:00
|
|
|
import Dropdown from '../../dropdown';
|
2023-06-26 17:10:26 +08:00
|
|
|
import Empty from '../../empty';
|
2023-09-14 17:04:05 +08:00
|
|
|
import Flex from '../../flex';
|
2024-03-19 17:14:22 +08:00
|
|
|
import FloatButton from '../../float-button';
|
2023-06-28 14:13:14 +08:00
|
|
|
import Form from '../../form';
|
2023-06-25 14:46:13 +08:00
|
|
|
import Image from '../../image';
|
2023-06-28 11:53:26 +08:00
|
|
|
import Input from '../../input';
|
2023-06-28 13:51:24 +08:00
|
|
|
import Layout from '../../layout';
|
2023-07-06 09:43:03 +08:00
|
|
|
import List from '../../list';
|
2023-06-27 10:51:23 +08:00
|
|
|
import Mentions from '../../mentions';
|
2023-07-05 19:48:33 +08:00
|
|
|
import Menu from '../../menu';
|
2024-02-26 09:55:08 +08:00
|
|
|
import type { MenuProps } from '../../menu';
|
2023-07-03 20:38:14 +08:00
|
|
|
import message from '../../message';
|
2023-06-27 17:14:08 +08:00
|
|
|
import Modal from '../../modal';
|
2023-07-03 20:37:11 +08:00
|
|
|
import notification from '../../notification';
|
2023-06-26 15:32:18 +08:00
|
|
|
import Pagination from '../../pagination';
|
2023-07-05 19:21:56 +08:00
|
|
|
import Progress from '../../progress';
|
2023-06-26 19:07:57 +08:00
|
|
|
import Radio from '../../radio';
|
2023-06-29 19:30:34 +08:00
|
|
|
import Rate from '../../rate';
|
2023-06-25 16:20:39 +08:00
|
|
|
import Result from '../../result';
|
2023-06-25 09:32:53 +08:00
|
|
|
import Segmented from '../../segmented';
|
2023-06-27 17:12:36 +08:00
|
|
|
import Select from '../../select';
|
2023-07-05 19:48:33 +08:00
|
|
|
import Skeleton from '../../skeleton';
|
2023-06-25 17:28:00 +08:00
|
|
|
import Slider from '../../slider';
|
2023-06-19 19:30:16 +08:00
|
|
|
import Space from '../../space';
|
2023-06-20 19:34:45 +08:00
|
|
|
import Spin from '../../spin';
|
2023-07-06 21:54:54 +08:00
|
|
|
import Statistic from '../../statistic';
|
2023-06-25 11:42:31 +08:00
|
|
|
import Steps from '../../steps';
|
2023-06-30 11:29:39 +08:00
|
|
|
import Switch from '../../switch';
|
2023-06-30 20:42:43 +08:00
|
|
|
import Table from '../../table';
|
2023-07-03 13:38:38 +08:00
|
|
|
import Tabs from '../../tabs';
|
2023-06-30 17:19:27 +08:00
|
|
|
import Tag from '../../tag';
|
2023-07-07 19:02:55 +08:00
|
|
|
import TimePicker from '../../time-picker';
|
2023-07-06 10:27:39 +08:00
|
|
|
import Timeline from '../../timeline';
|
2024-01-29 11:01:30 +08:00
|
|
|
import Tour from '../../tour';
|
2023-07-06 09:36:45 +08:00
|
|
|
import Transfer from '../../transfer';
|
2023-07-03 22:42:46 +08:00
|
|
|
import Tree from '../../tree';
|
2023-06-20 14:35:05 +08:00
|
|
|
import Typography from '../../typography';
|
2023-07-03 16:38:56 +08:00
|
|
|
import Upload from '../../upload';
|
2024-06-21 17:47:09 +08:00
|
|
|
import InputNumber from '../../input-number';
|
|
|
|
import TreeSelect from '../../tree-select';
|
2023-06-19 19:30:16 +08:00
|
|
|
|
|
|
|
describe('ConfigProvider support style and className props', () => {
|
|
|
|
it('Should Space classNames works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
space={{
|
|
|
|
classNames: {
|
|
|
|
item: 'test-classNames',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Space>
|
|
|
|
<span>Text1</span>
|
|
|
|
<span>Text2</span>
|
|
|
|
</Space>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
2023-06-20 14:35:05 +08:00
|
|
|
expect(container.querySelector('.ant-space-item')).toHaveClass('test-classNames');
|
2023-06-19 19:30:16 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Space className works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
space={{
|
|
|
|
className: 'test-classNames',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Space>
|
|
|
|
<span>Text1</span>
|
|
|
|
<span>Text2</span>
|
|
|
|
</Space>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
2023-06-20 14:35:05 +08:00
|
|
|
expect(container.querySelector('.ant-space')).toHaveClass('test-classNames');
|
2023-06-19 19:30:16 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Space styles works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
space={{
|
|
|
|
styles: {
|
|
|
|
item: {
|
|
|
|
color: 'red',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Space>
|
|
|
|
<span>Text1</span>
|
|
|
|
<span>Text2</span>
|
|
|
|
</Space>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
2023-09-05 10:17:56 +08:00
|
|
|
expect(container.querySelector('.ant-space-item')).toHaveStyle('color: red;');
|
2023-06-19 19:30:16 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Space style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
space={{
|
|
|
|
style: {
|
|
|
|
color: 'red',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Space>
|
|
|
|
<span>Text1</span>
|
|
|
|
<span>Text2</span>
|
|
|
|
</Space>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
2023-06-20 14:35:05 +08:00
|
|
|
expect(container.querySelector('.ant-space')).toHaveStyle('color: red;');
|
2023-06-19 19:30:16 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Divider className works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
divider={{
|
|
|
|
className: 'config-provider-className',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Divider />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
expect(container.querySelector('.ant-divider')).toHaveClass('config-provider-className');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Divider style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
divider={{
|
|
|
|
style: {
|
|
|
|
color: 'red',
|
|
|
|
height: 80,
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Divider />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
expect(container.querySelector('.ant-divider'))?.toHaveStyle({ color: 'red', height: '80px' });
|
|
|
|
});
|
2023-06-20 14:35:05 +08:00
|
|
|
|
2024-01-26 10:52:17 +08:00
|
|
|
it('Should Drawer className & closeIcon works', () => {
|
2023-07-06 10:42:13 +08:00
|
|
|
render(
|
|
|
|
<ConfigProvider
|
|
|
|
drawer={{
|
|
|
|
className: 'test-class',
|
2024-01-26 10:52:17 +08:00
|
|
|
closeIcon: <span className="cp-test-close-icon">close</span>,
|
2023-07-06 10:42:13 +08:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Drawer title="Test Drawer" open />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
2024-01-26 10:52:17 +08:00
|
|
|
const selectors = '.ant-drawer-content .ant-drawer-close .cp-test-close-icon';
|
2023-07-06 10:42:13 +08:00
|
|
|
expect(document.querySelector('.ant-drawer-content')).toHaveClass('test-class');
|
2024-01-26 10:52:17 +08:00
|
|
|
expect(document.querySelector<HTMLSpanElement>(selectors)).toBeTruthy();
|
2023-07-06 10:42:13 +08:00
|
|
|
});
|
|
|
|
|
2024-02-28 14:11:15 +08:00
|
|
|
it('Should support closable', () => {
|
|
|
|
render(
|
|
|
|
<ConfigProvider
|
|
|
|
drawer={{
|
|
|
|
closable: {
|
|
|
|
closeIcon: <span className="cp-test-close-icon">close</span>,
|
|
|
|
'aria-label': 'Close Btn',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Drawer title="Test Drawer" open />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
const selectors = '.ant-drawer-content .ant-drawer-close .cp-test-close-icon';
|
|
|
|
expect(document.querySelector<HTMLSpanElement>(selectors)).toBeTruthy();
|
|
|
|
expect(document.querySelector('*[aria-label="Close Btn"]')).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
2023-07-06 10:42:13 +08:00
|
|
|
it('Should Drawer style works', () => {
|
|
|
|
render(
|
|
|
|
<ConfigProvider
|
|
|
|
drawer={{
|
|
|
|
style: { color: 'red' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Drawer title="Test Drawer" style={{ fontSize: '16px' }} open />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(document.querySelector('.ant-drawer-content')).toHaveStyle(
|
|
|
|
'color: red; font-size: 16px;',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2023-07-07 09:30:37 +08:00
|
|
|
it('Should Carousel className works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
carousel={{
|
|
|
|
className: 'test-class',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Carousel>
|
|
|
|
<div>
|
|
|
|
<h3>test item</h3>
|
|
|
|
</div>
|
|
|
|
</Carousel>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.slick-slider')).toHaveClass('test-class');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Carousel style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider carousel={{ style: { color: 'red' } }}>
|
|
|
|
<Carousel style={{ fontSize: '16px' }}>
|
|
|
|
<div>
|
|
|
|
<h3>test item 1</h3>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<h3>test item 2</h3>
|
|
|
|
</div>
|
|
|
|
</Carousel>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.slick-slider')).toHaveStyle('color: red; font-size: 16px;');
|
|
|
|
});
|
|
|
|
|
2023-06-27 17:13:27 +08:00
|
|
|
it('Should Cascader className & style works', () => {
|
|
|
|
const options = [
|
|
|
|
{
|
|
|
|
value: 'zhejiang',
|
|
|
|
label: 'Zhejiang',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
value: 'hangzhou',
|
|
|
|
label: 'Hangzhou',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
value: 'xihu',
|
|
|
|
label: 'West Lake',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 'jiangsu',
|
|
|
|
label: 'Jiangsu',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
value: 'nanjing',
|
|
|
|
label: 'Nanjing',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
value: 'zhonghuamen',
|
|
|
|
label: 'Zhong Hua Men',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider cascader={{ className: 'cp-cascader', style: { backgroundColor: 'red' } }}>
|
|
|
|
<Cascader open options={options} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
const element = container.querySelector<HTMLElement>('.ant-cascader');
|
|
|
|
expect(element).toHaveClass('cp-cascader');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'red' });
|
|
|
|
});
|
|
|
|
|
2024-02-20 14:02:43 +08:00
|
|
|
it('Should Collapse className & expandIcon works', () => {
|
2023-07-06 09:45:25 +08:00
|
|
|
const items = [
|
|
|
|
{
|
|
|
|
key: '1',
|
|
|
|
label: 'test label',
|
|
|
|
children: <p>item</p>,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
collapse={{
|
|
|
|
className: 'test-class',
|
2024-02-20 14:02:43 +08:00
|
|
|
expandIcon: (props) => <span className="cp-test-icon">{props.isActive}</span>,
|
2023-07-06 09:45:25 +08:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Collapse items={items} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
expect(container.querySelector('.ant-collapse')).toHaveClass('test-class');
|
2024-02-20 14:02:43 +08:00
|
|
|
expect(container.querySelector<HTMLSpanElement>('.cp-test-icon')).toBeTruthy();
|
2023-07-06 09:45:25 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Collapse style works', () => {
|
|
|
|
const items = [
|
|
|
|
{
|
|
|
|
key: '1',
|
|
|
|
label: 'test label',
|
|
|
|
children: <p>item</p>,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
collapse={{
|
|
|
|
style: { color: 'red' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Collapse items={items} style={{ fontSize: '16px' }} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-collapse')).toHaveStyle('color: red; font-size: 16px;');
|
|
|
|
});
|
|
|
|
|
2023-06-20 14:35:05 +08:00
|
|
|
it('Should Typography className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
typography={{ className: 'cp-typography', style: { backgroundColor: 'red' } }}
|
|
|
|
>
|
|
|
|
<Typography>test</Typography>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLElement>('.ant-typography');
|
|
|
|
expect(element).toHaveClass('cp-typography');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'red' });
|
|
|
|
});
|
2023-06-20 19:34:45 +08:00
|
|
|
|
2023-07-05 18:00:46 +08:00
|
|
|
it('Should Skeleton className works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
skeleton={{
|
|
|
|
className: 'test-class',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Skeleton />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-skeleton')).toHaveClass('test-class');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Skeleton style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
skeleton={{
|
|
|
|
style: { color: 'red' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Skeleton style={{ fontSize: '16px' }} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-skeleton')).toHaveStyle('color: red; font-size: 16px;');
|
|
|
|
});
|
|
|
|
|
2023-06-20 19:34:45 +08:00
|
|
|
it('Should Spin className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
spin={{ className: 'config-provider-spin', style: { backgroundColor: 'red' } }}
|
|
|
|
>
|
|
|
|
<Spin />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLDivElement>('.ant-spin');
|
|
|
|
expect(element).toHaveClass('config-provider-spin');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'red' });
|
|
|
|
});
|
2023-06-25 09:32:53 +08:00
|
|
|
|
2023-07-06 21:54:54 +08:00
|
|
|
it('Should Statistic className works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
statistic={{
|
|
|
|
className: 'test-class',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Statistic title="Test Title" value={100} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-statistic')).toHaveClass('test-class');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Statistic style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
statistic={{
|
|
|
|
style: { color: 'red' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Statistic style={{ fontSize: '16px' }} title="Test Title" value={100} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-statistic')).toHaveStyle('color: red; font-size: 16px;');
|
|
|
|
});
|
|
|
|
|
2023-06-25 09:32:53 +08:00
|
|
|
it('Should Segmented className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
segmented={{ className: 'config-provider-segmented', style: { backgroundColor: 'red' } }}
|
|
|
|
>
|
|
|
|
<Segmented options={['Daily', 'Weekly', 'Monthly', 'Quarterly', 'Yearly']} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLDivElement>('.ant-segmented');
|
|
|
|
expect(element).toHaveClass('config-provider-segmented');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'red' });
|
|
|
|
});
|
2023-06-25 11:42:31 +08:00
|
|
|
|
2023-06-27 17:12:36 +08:00
|
|
|
it('Should Select className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider select={{ className: 'cp-select', style: { backgroundColor: 'red' } }}>
|
|
|
|
<Select
|
|
|
|
options={[
|
|
|
|
{ value: 'jack', label: 'Jack' },
|
|
|
|
{ value: 'lucy', label: 'Lucy' },
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLDivElement>('.ant-select');
|
|
|
|
expect(element).toHaveClass('cp-select');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'red' });
|
|
|
|
});
|
|
|
|
|
2023-06-25 11:42:31 +08:00
|
|
|
it('Should Steps className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
steps={{ className: 'config-provider-steps', style: { backgroundColor: 'red' } }}
|
|
|
|
>
|
|
|
|
<Steps items={[{ title: 'title', description: 'description' }]} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLDivElement>('.ant-steps');
|
|
|
|
expect(element).toHaveClass('config-provider-steps');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'red' });
|
|
|
|
});
|
2023-06-25 14:46:13 +08:00
|
|
|
|
2023-06-28 14:13:14 +08:00
|
|
|
it('Should Form className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider form={{ className: 'cp-form', style: { backgroundColor: 'red' } }}>
|
|
|
|
<Form name="basic">
|
|
|
|
<Form.Item label="Username" name="username">
|
|
|
|
<Input />
|
|
|
|
</Form.Item>
|
|
|
|
</Form>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
const element = container.querySelector<HTMLDivElement>('.ant-form');
|
|
|
|
expect(element).toHaveClass('cp-form');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'red' });
|
|
|
|
});
|
|
|
|
|
2024-02-01 17:43:00 +08:00
|
|
|
it('Should Image className & style & closeIcon works', () => {
|
|
|
|
const { container, baseElement } = render(
|
2023-06-25 14:46:13 +08:00
|
|
|
<ConfigProvider
|
2024-02-01 17:43:00 +08:00
|
|
|
image={{
|
|
|
|
className: 'config-provider-image',
|
|
|
|
style: { backgroundColor: 'red' },
|
|
|
|
preview: { closeIcon: <span className="cp-test-closeIcon">cp-test-closeIcon</span> },
|
|
|
|
}}
|
2023-06-25 14:46:13 +08:00
|
|
|
>
|
|
|
|
<Image src="https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png" />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
2024-02-01 17:43:00 +08:00
|
|
|
const element = container?.querySelector<HTMLImageElement>('.ant-image img');
|
2023-06-25 14:46:13 +08:00
|
|
|
expect(element).toHaveClass('config-provider-image');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'red' });
|
2024-02-01 17:43:00 +08:00
|
|
|
fireEvent.click(container.querySelector<HTMLDivElement>('.ant-image')!);
|
|
|
|
expect(
|
|
|
|
baseElement.querySelector<HTMLSpanElement>('.ant-image-preview-close .cp-test-closeIcon'),
|
|
|
|
).toBeTruthy();
|
2023-06-25 14:46:13 +08:00
|
|
|
});
|
2023-06-25 16:20:39 +08:00
|
|
|
|
2024-02-27 10:25:35 +08:00
|
|
|
it('Should Input className & style & classNames & styles & autoComplete & allowClear works', () => {
|
2023-06-28 11:53:26 +08:00
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
input={{
|
|
|
|
className: 'cp-input',
|
|
|
|
style: { backgroundColor: 'red' },
|
|
|
|
classNames: {
|
|
|
|
input: 'cp-classNames-input',
|
|
|
|
prefix: 'cp-classNames-prefix',
|
|
|
|
},
|
|
|
|
styles: {
|
|
|
|
input: {
|
|
|
|
color: 'blue',
|
|
|
|
},
|
|
|
|
prefix: {
|
|
|
|
color: 'black',
|
|
|
|
},
|
|
|
|
},
|
2024-02-27 10:25:35 +08:00
|
|
|
allowClear: {
|
|
|
|
clearIcon: <span className="cp-test-icon">cp-test-icon</span>,
|
|
|
|
},
|
2024-02-28 09:54:48 +08:00
|
|
|
autoComplete: 'test-cp-autocomplete',
|
2023-06-28 11:53:26 +08:00
|
|
|
}}
|
|
|
|
>
|
2024-02-27 10:25:35 +08:00
|
|
|
<Input
|
|
|
|
autoComplete="test-autocomplete"
|
|
|
|
placeholder="Basic usage"
|
|
|
|
value="test"
|
|
|
|
prefix="¥"
|
|
|
|
/>
|
2023-06-28 11:53:26 +08:00
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
2024-02-27 10:25:35 +08:00
|
|
|
const wrapperElement = container.querySelector<HTMLSpanElement>('.ant-input-affix-wrapper');
|
2023-06-28 11:53:26 +08:00
|
|
|
expect(wrapperElement).toHaveClass('cp-input');
|
|
|
|
expect(wrapperElement).toHaveStyle({ backgroundColor: 'red' });
|
|
|
|
|
|
|
|
const prefixElement = container.querySelector<HTMLDivElement>('.ant-input-prefix');
|
|
|
|
expect(prefixElement).toHaveClass('cp-classNames-prefix');
|
|
|
|
expect(prefixElement).toHaveStyle({ color: 'black' });
|
|
|
|
|
|
|
|
const inputElement = container.querySelector<HTMLDivElement>('.ant-input');
|
|
|
|
expect(inputElement).toHaveClass('cp-classNames-input');
|
|
|
|
expect(inputElement).toHaveStyle({ color: 'blue' });
|
2024-02-27 10:25:35 +08:00
|
|
|
expect(inputElement?.getAttribute('autocomplete')).toBe('test-autocomplete');
|
2024-02-28 09:54:48 +08:00
|
|
|
expect(inputElement?.getAttribute('autocomplete')).not.toBe('test-cp-autocomplete');
|
|
|
|
expect(
|
|
|
|
container?.querySelector<HTMLSpanElement>('.ant-input-affix-wrapper .cp-test-icon'),
|
|
|
|
).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Input.TextArea autoComplete & className & style & classNames & styles & allowClear works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
textArea={{
|
|
|
|
className: 'cp-textArea',
|
|
|
|
style: { backgroundColor: 'yellow' },
|
|
|
|
classNames: {
|
|
|
|
textarea: 'cp-classNames-textArea',
|
|
|
|
count: 'cp-classNames-count',
|
|
|
|
},
|
|
|
|
styles: {
|
|
|
|
textarea: {
|
|
|
|
color: 'blue',
|
|
|
|
},
|
|
|
|
count: {
|
|
|
|
color: 'red',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
allowClear: {
|
|
|
|
clearIcon: <span className="cp-test-icon">cp-test-icon</span>,
|
|
|
|
},
|
|
|
|
autoComplete: 'test-cp-autocomplete',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Input.TextArea
|
|
|
|
autoComplete="test-autocomplete"
|
|
|
|
placeholder="Basic usage"
|
|
|
|
value="test"
|
|
|
|
prefix="¥"
|
|
|
|
count={{ show: true }}
|
|
|
|
/>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const wrapperElement = container.querySelector<HTMLSpanElement>('.ant-input-affix-wrapper');
|
|
|
|
expect(wrapperElement).toHaveClass('cp-textArea');
|
|
|
|
expect(wrapperElement).toHaveStyle({ backgroundColor: 'yellow' });
|
|
|
|
|
|
|
|
const inputElement = container.querySelector<HTMLTextAreaElement>('.ant-input');
|
|
|
|
expect(inputElement).toHaveClass('cp-classNames-textArea');
|
|
|
|
expect(inputElement).toHaveStyle({ color: 'blue' });
|
|
|
|
expect(inputElement?.getAttribute('autocomplete')).toBe('test-autocomplete');
|
|
|
|
expect(inputElement?.getAttribute('autocomplete')).not.toBe('test-cp-autocomplete');
|
|
|
|
|
|
|
|
const countElement = container.querySelector<HTMLSpanElement>(
|
|
|
|
'.ant-input-affix-wrapper .ant-input-data-count',
|
|
|
|
);
|
|
|
|
expect(countElement).toHaveClass('cp-classNames-count');
|
|
|
|
expect(countElement).toHaveStyle({ color: 'red' });
|
|
|
|
|
2024-02-27 10:25:35 +08:00
|
|
|
expect(
|
|
|
|
container?.querySelector<HTMLSpanElement>('.ant-input-affix-wrapper .cp-test-icon'),
|
|
|
|
).toBeTruthy();
|
2023-06-28 11:53:26 +08:00
|
|
|
});
|
|
|
|
|
2023-06-28 13:51:24 +08:00
|
|
|
it('Should Layout className & style works', () => {
|
|
|
|
const { baseElement } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
layout={{
|
|
|
|
className: 'cp-layout',
|
|
|
|
style: {
|
|
|
|
background: 'red',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Layout>
|
|
|
|
<Layout.Header>Header</Layout.Header>
|
|
|
|
<Layout.Content>Content</Layout.Content>
|
|
|
|
<Layout.Footer>Footer</Layout.Footer>
|
|
|
|
</Layout>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
const element = baseElement.querySelector<HTMLDivElement>('.ant-layout');
|
|
|
|
expect(element).toHaveClass('cp-layout');
|
|
|
|
expect(element).toHaveStyle({ background: 'red' });
|
|
|
|
});
|
2023-07-05 19:48:33 +08:00
|
|
|
|
2023-07-06 09:43:03 +08:00
|
|
|
it('Should List className works', () => {
|
|
|
|
const listData = [
|
|
|
|
{
|
|
|
|
title: 'Test Title',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
list={{
|
|
|
|
className: 'test-class',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<List dataSource={listData} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-list')).toHaveClass('test-class');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should List style works', () => {
|
|
|
|
const listData = [
|
|
|
|
{
|
|
|
|
title: 'Test Title',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
list={{
|
|
|
|
style: { color: 'red' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<List style={{ fontSize: '16px' }} dataSource={listData} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-list')).toHaveStyle('color: red; font-size: 16px;');
|
|
|
|
});
|
|
|
|
|
2024-02-26 09:55:08 +08:00
|
|
|
it('Should Menu className & expandIcon works', () => {
|
|
|
|
const menuItems: MenuProps['items'] = [
|
2023-07-05 19:48:33 +08:00
|
|
|
{
|
2024-02-26 09:55:08 +08:00
|
|
|
label: <span>Test Label</span>,
|
2023-07-05 19:48:33 +08:00
|
|
|
key: 'test',
|
2024-02-26 09:55:08 +08:00
|
|
|
children: [
|
|
|
|
{
|
|
|
|
label: <span>Test Label children</span>,
|
|
|
|
key: 'test-children',
|
|
|
|
},
|
|
|
|
],
|
2023-07-05 19:48:33 +08:00
|
|
|
},
|
|
|
|
];
|
2024-02-26 09:55:08 +08:00
|
|
|
const App: React.FC<{ expand?: React.ReactNode }> = ({ expand }) => (
|
|
|
|
<ConfigProvider menu={{ className: 'test-class', expandIcon: expand }}>
|
2023-07-05 19:48:33 +08:00
|
|
|
<Menu items={menuItems} />
|
2024-02-26 09:55:08 +08:00
|
|
|
</ConfigProvider>
|
2023-07-05 19:48:33 +08:00
|
|
|
);
|
2024-02-26 09:55:08 +08:00
|
|
|
const { container, rerender } = render(<App />);
|
|
|
|
expect(container.querySelector<HTMLElement>('.ant-menu')).toHaveClass('test-class');
|
|
|
|
rerender(<App expand={<span className="test-cp-icon">test-cp-icon</span>} />);
|
|
|
|
expect(container.querySelector<HTMLSpanElement>('.ant-menu .test-cp-icon')).toBeTruthy();
|
|
|
|
rerender(<App expand={null} />);
|
|
|
|
expect(container.querySelector<HTMLElement>('.ant-menu-submenu-arrow')).toBeFalsy();
|
|
|
|
rerender(<App expand={false} />);
|
|
|
|
expect(container.querySelector<HTMLElement>('.ant-menu-submenu-arrow')).toBeFalsy();
|
2023-07-05 19:48:33 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Menu style works', () => {
|
|
|
|
const menuItems = [
|
|
|
|
{
|
|
|
|
label: 'Test Label',
|
|
|
|
key: 'test',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
menu={{
|
|
|
|
style: { color: 'red' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Menu items={menuItems} style={{ fontSize: '16px' }} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-menu')).toHaveStyle('color: red; font-size: 16px;');
|
|
|
|
});
|
2023-06-28 13:51:24 +08:00
|
|
|
|
2023-06-27 10:51:23 +08:00
|
|
|
it('Should Mentions className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
mentions={{
|
|
|
|
className: 'cp-className',
|
|
|
|
style: {
|
|
|
|
background: 'red',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Mentions
|
|
|
|
defaultValue="@afc163"
|
|
|
|
options={[
|
|
|
|
{
|
|
|
|
value: 'afc163',
|
|
|
|
label: 'afc163',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 'zombieJ',
|
|
|
|
label: 'zombieJ',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 'yesmeck',
|
|
|
|
label: 'yesmeck',
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-mentions')).toHaveClass('cp-className');
|
|
|
|
expect(container.querySelector('.ant-mentions')).toHaveStyle({ background: 'red' });
|
|
|
|
});
|
|
|
|
|
2024-01-30 14:42:46 +08:00
|
|
|
it('Should Modal className & style & closeIcon works', () => {
|
2023-06-27 17:14:08 +08:00
|
|
|
const { baseElement } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
modal={{
|
|
|
|
className: 'cp-modal',
|
2024-01-30 14:42:46 +08:00
|
|
|
style: { background: 'red' },
|
|
|
|
closeIcon: <span className="cp-test-closeIcon">cp-test-closeIcon</span>,
|
2023-06-27 17:14:08 +08:00
|
|
|
}}
|
|
|
|
>
|
2024-01-30 14:42:46 +08:00
|
|
|
<Modal open>test</Modal>
|
2023-06-27 17:14:08 +08:00
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
2024-01-30 14:42:46 +08:00
|
|
|
const selectors = '.ant-modal-content .ant-modal-close .cp-test-closeIcon';
|
2023-06-27 17:14:08 +08:00
|
|
|
const element = baseElement.querySelector<HTMLDivElement>('.ant-modal');
|
|
|
|
expect(element).toHaveClass('cp-modal');
|
|
|
|
expect(element).toHaveStyle({ background: 'red' });
|
2024-01-30 14:42:46 +08:00
|
|
|
expect(element?.querySelector<HTMLSpanElement>(selectors)).toBeTruthy();
|
2023-06-27 17:14:08 +08:00
|
|
|
});
|
|
|
|
|
2023-06-25 16:20:39 +08:00
|
|
|
it('Should Result className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider result={{ className: 'cp-result', style: { backgroundColor: 'red' } }}>
|
|
|
|
<Result />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLDivElement>('.ant-result');
|
|
|
|
expect(element).toHaveClass('cp-result');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'red' });
|
|
|
|
});
|
2023-06-25 17:28:00 +08:00
|
|
|
|
2023-06-26 19:07:57 +08:00
|
|
|
it('Should Radio className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
radio={{
|
|
|
|
className: 'cp-className',
|
|
|
|
style: {
|
|
|
|
background: 'red',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Radio>Radio</Radio>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-radio-wrapper')).toHaveClass('cp-className');
|
|
|
|
expect(container.querySelector('.ant-radio-wrapper')).toHaveStyle({ background: 'red' });
|
|
|
|
});
|
|
|
|
|
2023-06-25 17:28:00 +08:00
|
|
|
it('Should Slider className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider slider={{ className: 'cp-slider', style: { backgroundColor: 'red' } }}>
|
|
|
|
<Slider />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLDivElement>('.ant-slider');
|
|
|
|
expect(element).toHaveClass('cp-slider');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'red' });
|
|
|
|
});
|
2023-06-25 18:28:57 +08:00
|
|
|
|
2023-07-06 09:33:54 +08:00
|
|
|
it('Should Alert className works', () => {
|
2024-02-19 13:40:19 +08:00
|
|
|
const { container, rerender } = render(
|
2023-07-06 09:33:54 +08:00
|
|
|
<ConfigProvider
|
|
|
|
alert={{
|
|
|
|
className: 'test-class',
|
2024-01-30 16:47:42 +08:00
|
|
|
closeIcon: <span className="cp-test-icon">cp-test-icon</span>,
|
2024-02-19 13:40:19 +08:00
|
|
|
closable: { 'aria-label': 'close' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Alert message="Test Message" />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
expect(container.querySelector<HTMLDivElement>('.ant-alert')).toHaveClass('test-class');
|
|
|
|
expect(container.querySelector<HTMLSpanElement>('.ant-alert .cp-test-icon')).toBeTruthy();
|
|
|
|
expect(container.querySelectorAll('*[aria-label="close"]')).toBeTruthy();
|
|
|
|
rerender(
|
|
|
|
<ConfigProvider
|
|
|
|
alert={{
|
|
|
|
className: 'test-class',
|
|
|
|
closable: {
|
|
|
|
'aria-label': 'close',
|
|
|
|
closeIcon: <span className="cp-test-icon">cp-test-icon</span>,
|
|
|
|
},
|
2023-07-06 09:33:54 +08:00
|
|
|
}}
|
|
|
|
>
|
2024-02-19 13:40:19 +08:00
|
|
|
<Alert message="Test Message" />
|
2023-07-06 09:33:54 +08:00
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
2024-02-19 13:40:19 +08:00
|
|
|
|
2024-01-30 16:47:42 +08:00
|
|
|
expect(container.querySelector<HTMLDivElement>('.ant-alert')).toHaveClass('test-class');
|
|
|
|
expect(container.querySelector<HTMLSpanElement>('.ant-alert .cp-test-icon')).toBeTruthy();
|
2024-02-19 13:40:19 +08:00
|
|
|
expect(container.querySelectorAll('*[aria-label="close"]')).toBeTruthy();
|
2023-07-06 09:33:54 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Alert style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
alert={{
|
|
|
|
style: { color: 'red' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Alert style={{ fontSize: '16px' }} message="Test Message" />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-alert')).toHaveStyle('color: red; font-size: 16px;');
|
|
|
|
});
|
|
|
|
|
2023-06-26 17:09:55 +08:00
|
|
|
it('Should Anchor className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
anchor={{
|
|
|
|
className: 'cp-className',
|
|
|
|
style: {
|
|
|
|
background: 'red',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Anchor
|
|
|
|
items={[
|
|
|
|
{
|
|
|
|
key: 'part-1',
|
|
|
|
href: '#part-1',
|
|
|
|
title: 'Part 1',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: 'part-2',
|
|
|
|
href: '#part-2',
|
|
|
|
title: 'Part 2',
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-anchor-wrapper')).toHaveClass('cp-className');
|
|
|
|
expect(container.querySelector('.ant-anchor-wrapper')).toHaveStyle({ background: 'red' });
|
|
|
|
});
|
|
|
|
|
2023-06-25 18:28:57 +08:00
|
|
|
it('Should Breadcrumb className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
breadcrumb={{ className: 'cp-breadcrumb', style: { backgroundColor: 'red' } }}
|
|
|
|
>
|
|
|
|
<Breadcrumb />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLElement>('.ant-breadcrumb');
|
|
|
|
expect(element).toHaveClass('cp-breadcrumb');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'red' });
|
|
|
|
});
|
2023-06-26 11:42:46 +08:00
|
|
|
|
|
|
|
it('Should Checkbox className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
checkbox={{
|
2023-06-26 15:32:18 +08:00
|
|
|
className: 'cp-checkbox',
|
2023-06-26 11:42:46 +08:00
|
|
|
style: {
|
|
|
|
background: 'red',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Checkbox>Checkbox</Checkbox>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
2023-06-26 15:32:18 +08:00
|
|
|
expect(container.querySelector('.ant-checkbox-wrapper')).toHaveClass('cp-checkbox');
|
2023-06-26 11:42:46 +08:00
|
|
|
expect(container.querySelector('.ant-checkbox-wrapper')).toHaveStyle({ background: 'red' });
|
|
|
|
});
|
2023-06-26 14:38:02 +08:00
|
|
|
|
2023-06-26 15:32:18 +08:00
|
|
|
it('Should Pagination className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
pagination={{ className: 'cp-pagination', style: { backgroundColor: 'blue' } }}
|
|
|
|
>
|
|
|
|
<Pagination />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLUListElement>('.ant-pagination');
|
|
|
|
expect(element).toHaveClass('cp-pagination');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'blue' });
|
|
|
|
});
|
|
|
|
|
2023-07-05 19:21:56 +08:00
|
|
|
it('Should Progress className works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
progress={{
|
|
|
|
className: 'test-class',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Progress />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-progress')).toHaveClass('test-class');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Progress style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
progress={{
|
|
|
|
style: { color: 'red' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Progress style={{ fontSize: '16px' }} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-progress')).toHaveStyle('color: red; font-size: 16px;');
|
|
|
|
});
|
|
|
|
|
2023-06-26 14:38:02 +08:00
|
|
|
it('Should Descriptions className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
descriptions={{
|
|
|
|
className: 'cp-className',
|
|
|
|
style: {
|
|
|
|
background: 'red',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Descriptions title="User Info">
|
|
|
|
<Descriptions.Item label="UserName">muxin</Descriptions.Item>
|
|
|
|
</Descriptions>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-descriptions')).toHaveClass('cp-className');
|
|
|
|
expect(container.querySelector('.ant-descriptions')).toHaveStyle({ background: 'red' });
|
|
|
|
});
|
2023-06-26 17:10:26 +08:00
|
|
|
|
|
|
|
it('Should Empty className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
empty={{
|
|
|
|
className: 'cp-className',
|
|
|
|
style: {
|
|
|
|
background: 'red',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Empty />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-empty')).toHaveClass('cp-className');
|
|
|
|
expect(container.querySelector('.ant-empty')).toHaveStyle({ background: 'red' });
|
|
|
|
});
|
2023-06-29 16:43:11 +08:00
|
|
|
|
|
|
|
it('Should Badge className & style & classNames works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
badge={{
|
|
|
|
className: 'cp-badge',
|
|
|
|
style: {
|
|
|
|
backgroundColor: 'blue',
|
|
|
|
},
|
|
|
|
classNames: {
|
|
|
|
root: 'cp-badge-root',
|
|
|
|
indicator: 'cp-badge-indicator',
|
|
|
|
},
|
|
|
|
styles: {
|
|
|
|
root: { color: 'yellow' },
|
|
|
|
indicator: { color: 'green' },
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Badge count={10}>test</Badge>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLSpanElement>('.ant-badge');
|
|
|
|
|
|
|
|
// test className
|
|
|
|
expect(element).toHaveClass('cp-badge');
|
|
|
|
expect(element).toHaveClass('cp-badge-root');
|
|
|
|
expect(element?.querySelector<HTMLElement>('sup')).toHaveClass('cp-badge-indicator');
|
|
|
|
|
|
|
|
// test style
|
|
|
|
expect(element).toHaveStyle({ color: 'yellow' });
|
|
|
|
expect(element?.querySelector<HTMLElement>('sup')).toHaveStyle({
|
|
|
|
color: 'green',
|
|
|
|
backgroundColor: 'blue',
|
|
|
|
});
|
|
|
|
});
|
2023-06-29 19:30:34 +08:00
|
|
|
|
|
|
|
it('Should Rate className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider rate={{ className: 'cp-rate', style: { backgroundColor: 'blue' } }}>
|
|
|
|
<Rate />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLUListElement>('.ant-rate');
|
|
|
|
expect(element).toHaveClass('cp-rate');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'blue' });
|
|
|
|
});
|
2023-06-30 11:29:39 +08:00
|
|
|
|
|
|
|
it('Should Switch className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider switch={{ className: 'cp-switch', style: { backgroundColor: 'blue' } }}>
|
|
|
|
<Switch />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLButtonElement>('.ant-switch');
|
|
|
|
expect(element).toHaveClass('cp-switch');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'blue' });
|
|
|
|
});
|
2023-06-30 17:19:27 +08:00
|
|
|
|
2023-07-03 10:27:31 +08:00
|
|
|
it('Should Avatar className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider avatar={{ className: 'cp-avatar', style: { backgroundColor: 'blue' } }}>
|
|
|
|
<Avatar />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLSpanElement>('.ant-avatar');
|
|
|
|
expect(element).toHaveClass('cp-avatar');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'blue' });
|
|
|
|
});
|
|
|
|
|
2024-01-31 10:07:16 +08:00
|
|
|
it('Should Tag className & style & closeIcon works', () => {
|
2023-06-30 17:19:27 +08:00
|
|
|
const { container } = render(
|
2024-01-31 10:07:16 +08:00
|
|
|
<ConfigProvider
|
|
|
|
tag={{
|
|
|
|
className: 'cp-tag',
|
|
|
|
style: { backgroundColor: 'blue' },
|
|
|
|
closeIcon: <span className="cp-test-closeIcon">cp-test-closeIcon</span>,
|
|
|
|
}}
|
|
|
|
>
|
2023-06-30 17:19:27 +08:00
|
|
|
<Tag>Test</Tag>
|
2023-09-03 10:20:24 +08:00
|
|
|
<Tag.CheckableTag checked>CheckableTag</Tag.CheckableTag>
|
2023-06-30 17:19:27 +08:00
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLSpanElement>('.ant-tag');
|
|
|
|
expect(element).toHaveClass('cp-tag');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'blue' });
|
2023-09-03 10:20:24 +08:00
|
|
|
|
|
|
|
const checkableElement = container.querySelector<HTMLSpanElement>('.ant-tag-checkable');
|
|
|
|
expect(checkableElement).toHaveClass('cp-tag');
|
|
|
|
expect(checkableElement).toHaveStyle({ backgroundColor: 'blue' });
|
2024-01-31 10:07:16 +08:00
|
|
|
expect(element?.querySelector<HTMLSpanElement>('.cp-test-closeIcon')).toBeTruthy();
|
2023-06-30 17:19:27 +08:00
|
|
|
});
|
2023-06-30 20:42:43 +08:00
|
|
|
|
2024-03-31 11:56:55 +08:00
|
|
|
it('Should Tag support aria-* in closable', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
tag={{
|
|
|
|
closable: {
|
|
|
|
closeIcon: <span className="cp-test-closeIcon">cp-test-closeIcon</span>,
|
|
|
|
'aria-label': 'Close Tag',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Tag>Test</Tag>
|
|
|
|
<Tag.CheckableTag checked>CheckableTag</Tag.CheckableTag>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLSpanElement>('.ant-tag');
|
|
|
|
expect(element?.querySelector('.ant-tag-close-icon')).toBeTruthy();
|
|
|
|
expect(element?.querySelector('.ant-tag-close-icon')?.getAttribute('aria-label')).toBe(
|
|
|
|
'Close Tag',
|
|
|
|
);
|
|
|
|
expect(element?.querySelector('.cp-test-closeIcon')).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Tag hide closeIcon when closeIcon=false', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
tag={{
|
|
|
|
closeIcon: false,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Tag>Test</Tag>
|
|
|
|
<Tag.CheckableTag checked>CheckableTag</Tag.CheckableTag>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLSpanElement>('.ant-tag');
|
|
|
|
expect(element?.querySelector('.ant-tag-close-icon')).toBeFalsy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Tag show default closeIcon when closeIcon=true', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
tag={{
|
|
|
|
closeIcon: true,
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Tag>Test</Tag>
|
|
|
|
<Tag.CheckableTag checked>CheckableTag</Tag.CheckableTag>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLSpanElement>('.ant-tag');
|
|
|
|
expect(element?.querySelector('.ant-tag-close-icon')).toBeTruthy();
|
|
|
|
expect(element?.querySelector('.anticon-close')).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
2023-06-30 20:42:43 +08:00
|
|
|
it('Should Table className & style works', () => {
|
|
|
|
const { container } = render(
|
2024-01-30 13:57:49 +08:00
|
|
|
<ConfigProvider
|
|
|
|
table={{
|
|
|
|
className: 'cp-table',
|
|
|
|
style: { backgroundColor: 'blue' },
|
|
|
|
expandable: { expandIcon: () => <span className="cp-test-icon">cp-test-icon</span> },
|
|
|
|
}}
|
|
|
|
>
|
2024-01-13 14:27:42 +08:00
|
|
|
<Table
|
|
|
|
columns={[{ title: 'Address', dataIndex: 'address', key: 'address 1', ellipsis: true }]}
|
|
|
|
dataSource={[{ key: '1', name: 'Jim Green', age: 40, address: 'test', tags: ['loser'] }]}
|
|
|
|
/>
|
2023-06-30 20:42:43 +08:00
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLDivElement>('.ant-table-wrapper');
|
|
|
|
expect(element).toHaveClass('cp-table');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'blue' });
|
2024-01-30 13:57:49 +08:00
|
|
|
expect(container.querySelector<HTMLSpanElement>('.ant-table-tbody .cp-test-icon')).toBeTruthy();
|
2023-06-30 20:42:43 +08:00
|
|
|
});
|
2023-07-03 10:25:55 +08:00
|
|
|
|
2023-07-06 09:38:21 +08:00
|
|
|
it('Should Calendar className works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
calendar={{
|
|
|
|
className: 'test-class',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Calendar />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-picker-calendar')).toHaveClass('test-class');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Calendar style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
calendar={{
|
|
|
|
style: { color: 'red' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Calendar style={{ fontSize: '16px' }} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-picker-calendar')).toHaveStyle(
|
|
|
|
'color: red; font-size: 16px;',
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2024-01-30 15:00:25 +08:00
|
|
|
it('Should Card className & style & classNames & styles works', () => {
|
2023-07-03 10:25:55 +08:00
|
|
|
const { container } = render(
|
2024-01-30 15:00:25 +08:00
|
|
|
<ConfigProvider
|
|
|
|
card={{
|
|
|
|
className: 'cp-card',
|
|
|
|
style: { backgroundColor: 'blue' },
|
|
|
|
classNames: { body: 'custom-body' },
|
|
|
|
styles: { body: { color: 'red' } },
|
|
|
|
}}
|
|
|
|
>
|
2023-07-03 10:25:55 +08:00
|
|
|
<Card>test</Card>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLDivElement>('.ant-card');
|
|
|
|
expect(element).toHaveClass('cp-card');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'blue' });
|
2024-01-30 15:00:25 +08:00
|
|
|
const head = container.querySelector<HTMLDivElement>('.ant-card-body');
|
|
|
|
expect(head).toHaveClass('custom-body');
|
|
|
|
expect(head).toHaveStyle({ color: 'red' });
|
2023-07-03 10:25:55 +08:00
|
|
|
});
|
2023-07-03 13:38:38 +08:00
|
|
|
|
2024-02-05 11:45:24 +08:00
|
|
|
it('Should Tabs className & style & addIcon & moreIcon & removeIcon works', () => {
|
2023-07-03 13:38:38 +08:00
|
|
|
const { container } = render(
|
2024-02-01 19:14:54 +08:00
|
|
|
<ConfigProvider
|
|
|
|
tabs={{
|
|
|
|
className: 'cp-tabs',
|
|
|
|
style: { backgroundColor: 'red' },
|
|
|
|
addIcon: <span className="cp-test-addIcon">cp-test-addIcon</span>,
|
2024-04-17 12:05:43 +08:00
|
|
|
more: { icon: <span className="cp-test-moreIcon">cp-test-moreIcon</span> },
|
2024-02-05 11:45:24 +08:00
|
|
|
removeIcon: <span className="cp-test-removeIcon">cp-test-removeIcon</span>,
|
2024-02-01 19:14:54 +08:00
|
|
|
}}
|
|
|
|
>
|
2024-02-05 11:45:24 +08:00
|
|
|
<Tabs
|
|
|
|
type="editable-card"
|
|
|
|
items={[{ key: '1', label: <span>tab</span>, children: <span>children</span> }]}
|
|
|
|
/>
|
2023-07-03 13:38:38 +08:00
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLDivElement>('.ant-tabs');
|
|
|
|
expect(element).toHaveClass('cp-tabs');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'red' });
|
2024-02-01 19:14:54 +08:00
|
|
|
expect(element?.querySelector<HTMLSpanElement>('.cp-test-addIcon')).toBeTruthy();
|
|
|
|
expect(element?.querySelector<HTMLSpanElement>('.cp-test-moreIcon')).toBeTruthy();
|
2024-02-05 11:45:24 +08:00
|
|
|
expect(element?.querySelector<HTMLSpanElement>('.cp-test-removeIcon')).toBeTruthy();
|
2023-07-03 13:38:38 +08:00
|
|
|
});
|
2023-07-03 16:38:56 +08:00
|
|
|
|
2023-07-07 19:02:55 +08:00
|
|
|
it('Should TimePicker className works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
timePicker={{
|
|
|
|
className: 'test-class',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<TimePicker />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-picker')).toHaveClass('test-class');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should TimePicker style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
timePicker={{
|
|
|
|
style: { color: 'red' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<TimePicker style={{ fontSize: '16px' }} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-picker')).toHaveStyle('color: red; font-size: 16px;');
|
|
|
|
});
|
|
|
|
|
2023-10-24 00:57:38 +08:00
|
|
|
it('Should RangePicker className works', () => {
|
|
|
|
const { RangePicker } = TimePicker;
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
rangePicker={{
|
|
|
|
className: 'test-class',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<RangePicker />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
expect(container.querySelector('.ant-picker')).toHaveClass('test-class');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should RangePicker style works', () => {
|
|
|
|
const { RangePicker } = TimePicker;
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
rangePicker={{
|
|
|
|
style: { color: 'red' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<RangePicker style={{ fontSize: '16px' }} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
expect(container.querySelector('.ant-picker')).toHaveStyle('color: red; font-size: 16px;');
|
|
|
|
});
|
|
|
|
|
2023-07-03 20:38:14 +08:00
|
|
|
it('Should message className & style works', () => {
|
|
|
|
const Demo: React.FC = () => {
|
|
|
|
const [messageApi, contextHolder] = message.useMessage();
|
|
|
|
return (
|
|
|
|
<ConfigProvider message={{ className: 'cp-message', style: { color: 'blue' } }}>
|
|
|
|
{contextHolder}
|
|
|
|
<button type="button" onClick={() => messageApi.success('success')}>
|
|
|
|
test
|
|
|
|
</button>
|
|
|
|
</ConfigProvider>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
const { container } = render(<Demo />);
|
|
|
|
fireEvent.click(container.querySelector<HTMLButtonElement>('button')!);
|
|
|
|
const element = document
|
|
|
|
?.querySelector<HTMLDivElement>('.ant-message')
|
|
|
|
?.querySelector<HTMLDivElement>('.ant-message-notice');
|
|
|
|
expect(element).toHaveClass('cp-message');
|
|
|
|
expect(element).toHaveStyle({ color: 'blue' });
|
|
|
|
});
|
|
|
|
|
2023-07-03 16:38:56 +08:00
|
|
|
it('Should Upload className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider upload={{ className: 'cp-upload', style: { color: 'blue' } }}>
|
|
|
|
<Upload type="drag">upload</Upload>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container?.querySelector<HTMLSpanElement>('.ant-upload-wrapper');
|
|
|
|
expect(element).toHaveClass('cp-upload');
|
|
|
|
expect(element?.querySelector<HTMLDivElement>('.ant-upload')).toHaveStyle({ color: 'blue' });
|
|
|
|
});
|
2023-07-03 20:37:11 +08:00
|
|
|
|
2024-01-30 20:13:22 +08:00
|
|
|
it('Should notification className & style & closeIcon works', () => {
|
2023-07-03 20:37:11 +08:00
|
|
|
const Demo: React.FC = () => {
|
|
|
|
const [api, holder] = notification.useNotification();
|
|
|
|
return (
|
2024-01-30 20:13:22 +08:00
|
|
|
<ConfigProvider
|
|
|
|
notification={{
|
|
|
|
className: 'cp-notification',
|
|
|
|
style: { color: 'blue' },
|
|
|
|
closeIcon: <span className="cp-test-icon">cp-test-icon</span>,
|
|
|
|
}}
|
|
|
|
>
|
2023-07-03 20:37:11 +08:00
|
|
|
<button type="button" onClick={() => api.open({ message: 'test', duration: 0 })}>
|
|
|
|
test
|
|
|
|
</button>
|
|
|
|
{holder}
|
|
|
|
</ConfigProvider>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
const { container } = render(<Demo />);
|
|
|
|
fireEvent.click(container.querySelector<HTMLButtonElement>('button')!);
|
|
|
|
const element = document
|
|
|
|
?.querySelector<HTMLDivElement>('.ant-notification')
|
|
|
|
?.querySelector<HTMLDivElement>('.ant-notification-notice');
|
|
|
|
expect(element).toHaveClass('cp-notification');
|
|
|
|
expect(element).toHaveStyle({ color: 'blue' });
|
2024-01-30 20:13:22 +08:00
|
|
|
expect(element?.querySelector<HTMLSpanElement>('.ant-notification .cp-test-icon')).toBeTruthy();
|
2023-07-03 20:37:11 +08:00
|
|
|
});
|
2023-07-04 11:23:58 +08:00
|
|
|
|
2023-07-06 10:27:39 +08:00
|
|
|
it('Should Timeline className works', () => {
|
|
|
|
const items = [
|
|
|
|
{
|
|
|
|
children: 'test item',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
timeline={{
|
|
|
|
className: 'test-class',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Timeline items={items} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-timeline')).toHaveClass('test-class');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Timeline style works', () => {
|
|
|
|
const items = [
|
|
|
|
{
|
|
|
|
children: 'test item',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
timeline={{
|
|
|
|
style: { color: 'red' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Timeline items={items} style={{ fontSize: '16px' }} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-timeline')).toHaveStyle('color: red; font-size: 16px;');
|
|
|
|
});
|
|
|
|
|
2023-07-06 09:36:45 +08:00
|
|
|
it('Should Transfer className works', () => {
|
|
|
|
const mockData = [
|
|
|
|
{
|
|
|
|
key: '0-0',
|
|
|
|
title: `content`,
|
|
|
|
description: `description of content`,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
transfer={{
|
|
|
|
className: 'test-class',
|
2024-02-02 10:48:05 +08:00
|
|
|
selectionsIcon: <span className="cp-test-selectionsIcon">cp-test-selectionsIcon</span>,
|
2023-07-06 09:36:45 +08:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Transfer dataSource={mockData} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-transfer')).toHaveClass('test-class');
|
2024-02-02 10:48:05 +08:00
|
|
|
expect(container.querySelector<HTMLSpanElement>('.cp-test-selectionsIcon')).toBeTruthy();
|
2023-07-06 09:36:45 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Transfer style works', () => {
|
|
|
|
const mockData = [
|
|
|
|
{
|
|
|
|
key: '0-0',
|
|
|
|
title: `content`,
|
|
|
|
description: `description of content`,
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
transfer={{
|
|
|
|
style: {
|
|
|
|
color: 'red',
|
|
|
|
},
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Transfer dataSource={mockData} style={{ fontSize: '16px' }} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-transfer')).toHaveStyle('color: red; font-size: 16px;');
|
|
|
|
});
|
|
|
|
|
2023-07-03 22:42:46 +08:00
|
|
|
it('Should Tree className works', () => {
|
|
|
|
const treeData = [
|
|
|
|
{
|
|
|
|
title: 'test-title',
|
|
|
|
key: '0-0',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
tree={{
|
|
|
|
className: 'test-class',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Tree treeData={treeData} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-tree')).toHaveClass('test-class');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should Tree style works', () => {
|
|
|
|
const treeData = [
|
|
|
|
{
|
|
|
|
title: 'test-title',
|
|
|
|
key: '0-0',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
tree={{
|
|
|
|
style: { color: 'red' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Tree treeData={treeData} style={{ fontSize: '16px' }} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-tree-list')).toHaveStyle(
|
|
|
|
'color: red; font-size: 16px; position: relative;',
|
|
|
|
);
|
|
|
|
});
|
2023-07-04 11:23:58 +08:00
|
|
|
|
|
|
|
it('Should ColorPicker className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
colorPicker={{ className: 'cp-colorPicker', style: { backgroundColor: 'red' } }}
|
|
|
|
>
|
|
|
|
<ColorPicker />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLDivElement>('.ant-color-picker-trigger');
|
|
|
|
expect(element).toHaveClass('cp-colorPicker');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'red' });
|
|
|
|
});
|
2023-07-07 19:02:55 +08:00
|
|
|
|
|
|
|
it('Should DatePicker className works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
datePicker={{
|
|
|
|
className: 'test-class',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<DatePicker />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-picker')).toHaveClass('test-class');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should DatePicker style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
datePicker={{
|
|
|
|
style: { color: 'red' },
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<DatePicker style={{ fontSize: '16px' }} />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.ant-picker')).toHaveStyle('color: red; font-size: 16px;');
|
|
|
|
});
|
2023-09-14 17:04:05 +08:00
|
|
|
|
|
|
|
it('Should Flex className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider flex={{ className: 'cp-flex', style: { backgroundColor: 'blue' } }}>
|
|
|
|
<Flex>test</Flex>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLDivElement>('.ant-flex');
|
|
|
|
expect(element).toHaveClass('cp-flex');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'blue' });
|
|
|
|
});
|
2023-11-02 00:48:26 +08:00
|
|
|
|
|
|
|
it('Should Dropdown className & style works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider dropdown={{ className: 'cp-dropdown', style: { backgroundColor: 'red' } }}>
|
|
|
|
<Dropdown menu={{ items: [{ label: 'foo', key: '1' }] }} open>
|
|
|
|
<span>test</span>
|
|
|
|
</Dropdown>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLDivElement>('.ant-dropdown');
|
|
|
|
expect(element).toHaveClass('cp-dropdown');
|
|
|
|
expect(element).toHaveStyle({ backgroundColor: 'red' });
|
|
|
|
});
|
2024-01-29 11:01:30 +08:00
|
|
|
|
|
|
|
it('Should Tour closeIcon works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
tour={{ closeIcon: <span className="cp-test-closeIcon">cp-test-closeIcon</span> }}
|
|
|
|
>
|
|
|
|
<Tour steps={[{ title: 'test' }]} open />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const selectors = '.ant-tour .ant-tour-inner .ant-tour-close .cp-test-closeIcon';
|
|
|
|
const element = container.querySelector<HTMLSpanElement>(selectors);
|
|
|
|
expect(element).toBeTruthy();
|
|
|
|
});
|
2024-03-19 17:14:22 +08:00
|
|
|
|
|
|
|
it('Should FloatButton.Group closeIcon works', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
floatButtonGroup={{ closeIcon: <span className="test-cp-icon">test-cp-icon</span> }}
|
|
|
|
>
|
|
|
|
<FloatButton.Group trigger="click" open>
|
|
|
|
<FloatButton />
|
|
|
|
</FloatButton.Group>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
const element = container.querySelector<HTMLSpanElement>('.test-cp-icon');
|
|
|
|
expect(element).toBeTruthy();
|
|
|
|
});
|
2024-06-21 17:47:09 +08:00
|
|
|
|
|
|
|
it('should variant config work', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider
|
|
|
|
input={{ variant: 'filled' }}
|
|
|
|
inputNumber={{ variant: 'filled' }}
|
|
|
|
textArea={{ variant: 'filled' }}
|
|
|
|
mentions={{ variant: 'borderless' }}
|
|
|
|
select={{ variant: 'filled' }}
|
|
|
|
cascader={{ variant: 'outlined' }}
|
|
|
|
treeSelect={{ variant: 'borderless' }}
|
|
|
|
datePicker={{ variant: 'filled' }}
|
|
|
|
rangePicker={{ variant: 'filled' }}
|
|
|
|
timePicker={{ variant: 'borderless' }}
|
|
|
|
>
|
|
|
|
<Input className="input-variant" />
|
|
|
|
<InputNumber className="input-number-variant" />
|
|
|
|
<Input.TextArea className="textarea-variant" />
|
|
|
|
<Mentions className="mentions-variant" />
|
|
|
|
<Select className="select-variant" />
|
|
|
|
<Cascader className="cascader-variant" />
|
|
|
|
<TreeSelect className="tree-select-variant" />
|
|
|
|
<DatePicker className="date-picker-variant" />
|
|
|
|
<DatePicker.RangePicker className="range-picker-variant" />
|
|
|
|
<TimePicker className="time-picker-variant" />
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelector('.input-variant')).toHaveClass('ant-input-filled');
|
|
|
|
expect(container.querySelector('.input-number-variant')).toHaveClass('ant-input-number-filled');
|
|
|
|
expect(container.querySelector('.textarea-variant')).toHaveClass('ant-input-filled');
|
|
|
|
expect(container.querySelector('.mentions-variant')).toHaveClass('ant-mentions-borderless');
|
|
|
|
expect(container.querySelector('.select-variant')).toHaveClass('ant-select-filled');
|
|
|
|
expect(container.querySelector('.cascader-variant')).toHaveClass('ant-select-outlined');
|
|
|
|
expect(container.querySelector('.tree-select-variant')).toHaveClass('ant-select-borderless');
|
|
|
|
expect(container.querySelector('.date-picker-variant')).toHaveClass('ant-picker-filled');
|
|
|
|
expect(container.querySelector('.range-picker-variant')).toHaveClass('ant-picker-filled');
|
|
|
|
expect(container.querySelector('.time-picker-variant')).toHaveClass('ant-picker-borderless');
|
|
|
|
});
|
2023-06-19 19:30:16 +08:00
|
|
|
});
|