2022-06-22 14:57:09 +08:00
|
|
|
import React from 'react';
|
2023-08-30 22:09:32 +08:00
|
|
|
import MockDate from 'mockdate';
|
|
|
|
|
2019-05-22 23:22:09 +08:00
|
|
|
import Descriptions from '..';
|
2023-08-30 22:09:32 +08:00
|
|
|
import { resetWarned } from '../../_util/warning';
|
2019-08-26 22:53:20 +08:00
|
|
|
import mountTest from '../../../tests/shared/mountTest';
|
2022-08-09 19:32:40 +08:00
|
|
|
import { render } from '../../../tests/utils';
|
2023-05-10 14:09:25 +08:00
|
|
|
import ConfigProvider from '../../config-provider';
|
2019-05-22 23:22:09 +08:00
|
|
|
|
|
|
|
describe('Descriptions', () => {
|
2019-08-26 22:53:20 +08:00
|
|
|
mountTest(Descriptions);
|
|
|
|
|
2023-06-07 21:59:21 +08:00
|
|
|
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
2019-05-27 16:41:56 +08:00
|
|
|
|
|
|
|
afterEach(() => {
|
|
|
|
MockDate.reset();
|
|
|
|
errorSpy.mockReset();
|
|
|
|
});
|
|
|
|
|
|
|
|
afterAll(() => {
|
|
|
|
errorSpy.mockRestore();
|
|
|
|
});
|
|
|
|
|
2023-08-30 22:09:32 +08:00
|
|
|
it('when max-width: 575px, column=1', () => {
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper = render(
|
2019-05-22 23:22:09 +08:00
|
|
|
<Descriptions>
|
2019-05-27 21:32:45 +08:00
|
|
|
<Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Billing">Prepaid</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="time">18:00:00</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Amount">$80.00</Descriptions.Item>
|
2019-06-27 16:06:34 +08:00
|
|
|
<Descriptions.Item>No-Label</Descriptions.Item>
|
2019-05-22 23:22:09 +08:00
|
|
|
</Descriptions>,
|
|
|
|
);
|
2022-08-09 19:32:40 +08:00
|
|
|
expect(wrapper.container.querySelectorAll('tr')).toHaveLength(5);
|
|
|
|
expect(wrapper.container.querySelectorAll('.ant-descriptions-item-label')).toHaveLength(4);
|
2019-05-22 23:22:09 +08:00
|
|
|
wrapper.unmount();
|
|
|
|
});
|
|
|
|
|
2023-08-30 22:09:32 +08:00
|
|
|
it('when max-width: 575px, column=2', () => {
|
2019-05-22 23:22:09 +08:00
|
|
|
// eslint-disable-next-line global-require
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper = render(
|
2019-05-22 23:22:09 +08:00
|
|
|
<Descriptions column={{ xs: 2 }}>
|
2019-05-27 21:32:45 +08:00
|
|
|
<Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Billing">Prepaid</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="time">18:00:00</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Amount">$80.00</Descriptions.Item>
|
2019-05-22 23:22:09 +08:00
|
|
|
</Descriptions>,
|
|
|
|
);
|
2022-08-09 19:32:40 +08:00
|
|
|
expect(wrapper.container.querySelectorAll('tr')).toHaveLength(2);
|
2019-05-22 23:22:09 +08:00
|
|
|
wrapper.unmount();
|
|
|
|
});
|
|
|
|
|
2023-08-30 22:09:32 +08:00
|
|
|
it('when max-width: 575px, column=2, span=2', () => {
|
|
|
|
// eslint-disable-next-line global-require
|
|
|
|
const { container } = render(
|
|
|
|
<Descriptions
|
|
|
|
column={{ xs: 2 }}
|
|
|
|
items={[
|
|
|
|
{
|
|
|
|
label: 'Product',
|
|
|
|
children: 'Cloud Database',
|
|
|
|
span: { xs: 2 },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Billing',
|
|
|
|
children: 'Prepaid',
|
|
|
|
span: { xs: 1 },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Time',
|
|
|
|
children: '18:00:00',
|
|
|
|
span: { xs: 1 },
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(container.querySelectorAll('.ant-descriptions-item')[0]).toHaveAttribute('colSpan', '2');
|
|
|
|
expect(container.querySelectorAll('.ant-descriptions-item')[1]).toHaveAttribute('colSpan', '1');
|
|
|
|
expect(container.querySelectorAll('.ant-descriptions-item')[2]).toHaveAttribute('colSpan', '1');
|
|
|
|
});
|
|
|
|
|
2019-05-22 23:22:09 +08:00
|
|
|
it('column is number', () => {
|
|
|
|
// eslint-disable-next-line global-require
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper = render(
|
|
|
|
<Descriptions column={3}>
|
2019-05-27 21:32:45 +08:00
|
|
|
<Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Billing">Prepaid</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="time">18:00:00</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Amount">$80.00</Descriptions.Item>
|
2019-05-22 23:22:09 +08:00
|
|
|
</Descriptions>,
|
|
|
|
);
|
2022-08-09 19:32:40 +08:00
|
|
|
expect(wrapper.container.firstChild).toMatchSnapshot();
|
2019-05-22 23:22:09 +08:00
|
|
|
wrapper.unmount();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('when typeof column is object', () => {
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper = render(
|
2019-05-22 23:22:09 +08:00
|
|
|
<Descriptions column={{ xs: 8, sm: 16, md: 24 }}>
|
2019-05-27 21:32:45 +08:00
|
|
|
<Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Billing">Prepaid</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="time">18:00:00</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Amount">$80.00</Descriptions.Item>
|
2019-05-22 23:22:09 +08:00
|
|
|
</Descriptions>,
|
|
|
|
);
|
2022-08-09 19:32:40 +08:00
|
|
|
expect(
|
|
|
|
Array.from(wrapper.container.querySelectorAll('td'))
|
2022-11-19 13:47:33 +08:00
|
|
|
.map((i) => Number(i.getAttribute('colspan')))
|
2022-08-09 19:32:40 +08:00
|
|
|
.filter(Boolean)
|
|
|
|
.reduce((total, cur) => total + cur, 0),
|
|
|
|
).toBe(8);
|
2019-05-22 23:22:09 +08:00
|
|
|
wrapper.unmount();
|
|
|
|
});
|
2019-05-27 16:41:56 +08:00
|
|
|
|
2023-02-23 21:56:43 +08:00
|
|
|
it('warning if exceed the row span', () => {
|
2019-08-30 12:31:10 +08:00
|
|
|
resetWarned();
|
|
|
|
|
2022-08-09 19:32:40 +08:00
|
|
|
render(
|
2019-05-27 16:41:56 +08:00
|
|
|
<Descriptions column={3}>
|
2019-05-27 21:32:45 +08:00
|
|
|
<Descriptions.Item label="Product" span={2}>
|
2019-05-27 16:41:56 +08:00
|
|
|
Cloud Database
|
2019-05-27 21:32:45 +08:00
|
|
|
</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Billing" span={2}>
|
2019-05-27 16:41:56 +08:00
|
|
|
Prepaid
|
2019-05-27 21:32:45 +08:00
|
|
|
</Descriptions.Item>
|
2019-05-27 16:41:56 +08:00
|
|
|
</Descriptions>,
|
|
|
|
);
|
|
|
|
expect(errorSpy).toHaveBeenCalledWith(
|
2020-01-10 10:35:20 +08:00
|
|
|
'Warning: [antd: Descriptions] Sum of column `span` in a line not match `column` of Descriptions.',
|
2019-05-27 16:41:56 +08:00
|
|
|
);
|
|
|
|
});
|
2019-06-21 13:49:01 +08:00
|
|
|
|
|
|
|
it('when item is rendered conditionally', () => {
|
|
|
|
const hasDiscount = false;
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper = render(
|
2019-06-21 13:49:01 +08:00
|
|
|
<Descriptions>
|
|
|
|
<Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Billing">Prepaid</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="time">18:00:00</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Amount">$80.00</Descriptions.Item>
|
|
|
|
{hasDiscount && <Descriptions.Item label="Discount">$20.00</Descriptions.Item>}
|
|
|
|
</Descriptions>,
|
|
|
|
);
|
2022-08-09 19:32:40 +08:00
|
|
|
expect(wrapper.container.firstChild).toMatchSnapshot();
|
2019-06-21 13:49:01 +08:00
|
|
|
wrapper.unmount();
|
|
|
|
});
|
2019-06-27 11:29:33 +08:00
|
|
|
|
|
|
|
it('vertical layout', () => {
|
|
|
|
// eslint-disable-next-line global-require
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper = render(
|
2019-06-27 11:29:33 +08:00
|
|
|
<Descriptions layout="vertical">
|
|
|
|
<Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Billing">Prepaid</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="time">18:00:00</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Amount">$80.00</Descriptions.Item>
|
|
|
|
</Descriptions>,
|
|
|
|
);
|
2022-08-09 19:32:40 +08:00
|
|
|
expect(wrapper.container.firstChild).toMatchSnapshot();
|
2019-06-27 11:29:33 +08:00
|
|
|
wrapper.unmount();
|
|
|
|
});
|
2019-06-28 21:55:15 +08:00
|
|
|
|
2019-06-26 16:05:46 +08:00
|
|
|
it('Descriptions.Item support className', () => {
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper = render(
|
2019-06-26 16:05:46 +08:00
|
|
|
<Descriptions>
|
|
|
|
<Descriptions.Item label="Product" className="my-class">
|
|
|
|
Cloud Database
|
|
|
|
</Descriptions.Item>
|
|
|
|
</Descriptions>,
|
|
|
|
);
|
2022-08-09 19:32:40 +08:00
|
|
|
expect(wrapper.container.firstChild).toMatchSnapshot();
|
2019-06-26 16:05:46 +08:00
|
|
|
});
|
2019-07-10 10:32:02 +08:00
|
|
|
|
|
|
|
it('Descriptions support colon', () => {
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper = render(
|
2019-07-10 10:32:02 +08:00
|
|
|
<Descriptions colon={false}>
|
|
|
|
<Descriptions.Item label="Product">Cloud Database</Descriptions.Item>
|
|
|
|
</Descriptions>,
|
|
|
|
);
|
2022-08-09 19:32:40 +08:00
|
|
|
expect(wrapper.container.firstChild).toMatchSnapshot();
|
2019-07-10 10:32:02 +08:00
|
|
|
});
|
2019-07-15 10:01:37 +08:00
|
|
|
|
2019-07-10 10:01:31 +08:00
|
|
|
it('Descriptions support style', () => {
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper = render(
|
2019-07-10 10:01:31 +08:00
|
|
|
<Descriptions style={{ backgroundColor: '#e8e8e8' }}>
|
|
|
|
<Descriptions.Item>Cloud Database</Descriptions.Item>
|
|
|
|
</Descriptions>,
|
|
|
|
);
|
2022-08-09 19:32:40 +08:00
|
|
|
expect(wrapper.container.firstChild).toMatchSnapshot();
|
2019-07-10 10:01:31 +08:00
|
|
|
});
|
2019-08-30 15:56:44 +08:00
|
|
|
|
2023-12-11 00:05:47 +08:00
|
|
|
it('Descriptions support id', () => {
|
|
|
|
const wrapper = render(
|
|
|
|
<Descriptions id="descriptions">
|
|
|
|
<Descriptions.Item>Cloud Database</Descriptions.Item>
|
|
|
|
</Descriptions>,
|
|
|
|
);
|
|
|
|
const descriptionItemsElement = wrapper.container.querySelector('#descriptions');
|
|
|
|
expect(descriptionItemsElement).not.toBeNull();
|
|
|
|
});
|
|
|
|
|
2019-08-30 15:56:44 +08:00
|
|
|
it('keep key', () => {
|
2022-08-09 19:32:40 +08:00
|
|
|
render(
|
2019-08-30 15:56:44 +08:00
|
|
|
<Descriptions>
|
2022-08-09 19:32:40 +08:00
|
|
|
<Descriptions.Item key="bamboo">1</Descriptions.Item>
|
2019-08-30 15:56:44 +08:00
|
|
|
</Descriptions>,
|
|
|
|
);
|
2023-06-07 21:59:21 +08:00
|
|
|
expect(jest.spyOn(document, 'createElement')).not.toHaveBeenCalled();
|
2019-08-30 15:56:44 +08:00
|
|
|
});
|
2019-11-30 18:10:56 +08:00
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/19887
|
|
|
|
it('should work with React Fragment', () => {
|
|
|
|
if (!React.Fragment) {
|
|
|
|
return;
|
|
|
|
}
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper = render(
|
2019-11-30 18:10:56 +08:00
|
|
|
<Descriptions>
|
|
|
|
<Descriptions.Item label="bamboo">bamboo</Descriptions.Item>
|
|
|
|
<>
|
|
|
|
<Descriptions.Item label="bamboo">bamboo</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="bamboo">bamboo</Descriptions.Item>
|
|
|
|
</>
|
|
|
|
</Descriptions>,
|
|
|
|
);
|
|
|
|
|
2022-08-09 19:32:40 +08:00
|
|
|
expect(wrapper.container.firstChild).toMatchSnapshot();
|
2019-11-30 18:10:56 +08:00
|
|
|
});
|
2020-02-23 20:48:16 +08:00
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/20255
|
|
|
|
it('columns 5 with customize', () => {
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper = render(
|
2020-02-23 20:48:16 +08:00
|
|
|
<Descriptions layout="vertical" column={4}>
|
|
|
|
{/* 1 1 1 1 */}
|
|
|
|
<Descriptions.Item label="bamboo">bamboo</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="bamboo">bamboo</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="bamboo">bamboo</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="bamboo">bamboo</Descriptions.Item>
|
|
|
|
{/* 2 2 */}
|
|
|
|
<Descriptions.Item label="bamboo" span={2}>
|
|
|
|
bamboo
|
|
|
|
</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="bamboo" span={2}>
|
|
|
|
bamboo
|
|
|
|
</Descriptions.Item>
|
|
|
|
{/* 3 1 */}
|
|
|
|
<Descriptions.Item label="bamboo" span={3}>
|
|
|
|
bamboo
|
|
|
|
</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="bamboo">bamboo</Descriptions.Item>
|
|
|
|
</Descriptions>,
|
|
|
|
);
|
|
|
|
|
2022-08-09 19:32:40 +08:00
|
|
|
function matchSpan(rowIndex: number, spans: number[]) {
|
|
|
|
const trs = Array.from(wrapper.container.querySelectorAll('tr')).at(rowIndex);
|
|
|
|
const tds = Array.from(trs?.querySelectorAll('th')!);
|
2020-02-23 20:48:16 +08:00
|
|
|
expect(tds).toHaveLength(spans.length);
|
|
|
|
tds.forEach((td, index) => {
|
2022-08-09 19:32:40 +08:00
|
|
|
expect(Number(td.getAttribute('colSpan'))).toEqual(spans[index]);
|
2020-02-23 20:48:16 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
matchSpan(0, [1, 1, 1, 1]);
|
|
|
|
matchSpan(2, [2, 2]);
|
|
|
|
matchSpan(4, [3, 1]);
|
|
|
|
});
|
2020-03-05 17:54:58 +08:00
|
|
|
|
|
|
|
it('number value should render correct', () => {
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper = render(
|
2020-03-05 17:54:58 +08:00
|
|
|
<Descriptions bordered>
|
2022-08-09 19:32:40 +08:00
|
|
|
<Descriptions.Item label={0}>0</Descriptions.Item>
|
2020-03-05 17:54:58 +08:00
|
|
|
</Descriptions>,
|
|
|
|
);
|
2022-08-09 19:32:40 +08:00
|
|
|
expect(wrapper.container.querySelector('th')).toHaveClass('ant-descriptions-item-label');
|
|
|
|
expect(wrapper.container.querySelector('td')).toHaveClass('ant-descriptions-item-content');
|
2020-03-05 17:54:58 +08:00
|
|
|
});
|
2020-07-14 20:37:21 +08:00
|
|
|
|
|
|
|
it('Descriptions support extra', () => {
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper1 = render(
|
2020-07-14 20:37:21 +08:00
|
|
|
<Descriptions extra="Edit">
|
|
|
|
<Descriptions.Item label="UserName">Zhou Maomao</Descriptions.Item>
|
|
|
|
</Descriptions>,
|
|
|
|
);
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper2 = render(
|
|
|
|
<Descriptions>
|
|
|
|
<Descriptions.Item label="UserName">Zhou Maomao</Descriptions.Item>
|
|
|
|
</Descriptions>,
|
|
|
|
);
|
|
|
|
expect(wrapper1.container.querySelector('.ant-descriptions-extra')).toBeTruthy();
|
|
|
|
expect(wrapper2.container.querySelector('.ant-descriptions-extra')).toBeFalsy();
|
2020-07-14 20:37:21 +08:00
|
|
|
});
|
2022-03-25 09:38:55 +08:00
|
|
|
|
|
|
|
it('number 0 should render correct', () => {
|
2022-08-09 19:32:40 +08:00
|
|
|
const wrapper = render(
|
2022-03-25 09:38:55 +08:00
|
|
|
<Descriptions>
|
|
|
|
<Descriptions.Item label={0} labelStyle={{ color: 'red' }} contentStyle={{ color: 'red' }}>
|
|
|
|
{0}
|
|
|
|
</Descriptions.Item>
|
|
|
|
</Descriptions>,
|
|
|
|
);
|
2022-08-09 19:32:40 +08:00
|
|
|
expect(wrapper.container.firstChild).toMatchSnapshot();
|
2022-03-25 09:38:55 +08:00
|
|
|
});
|
2023-02-22 16:17:21 +08:00
|
|
|
|
|
|
|
it('should pass data-* and accessibility attributes', () => {
|
|
|
|
const { getByTestId } = render(
|
|
|
|
<Descriptions data-testid="test-id" data-id="12345" aria-describedby="some-label">
|
|
|
|
<Descriptions.Item label="banana">banana</Descriptions.Item>
|
|
|
|
</Descriptions>,
|
|
|
|
);
|
|
|
|
const container = getByTestId('test-id');
|
|
|
|
expect(container).toHaveAttribute('data-id', '12345');
|
|
|
|
expect(container).toHaveAttribute('aria-describedby', 'some-label');
|
|
|
|
});
|
2023-05-10 14:09:25 +08:00
|
|
|
|
2023-08-10 14:06:13 +08:00
|
|
|
it('Descriptions should inherit the size from ConfigProvider if the componentSize is set', () => {
|
2023-05-10 14:09:25 +08:00
|
|
|
const { container } = render(
|
|
|
|
<ConfigProvider componentSize="small">
|
|
|
|
<Descriptions bordered>
|
|
|
|
<Descriptions.Item label="small">small</Descriptions.Item>
|
|
|
|
</Descriptions>
|
|
|
|
</ConfigProvider>,
|
|
|
|
);
|
|
|
|
expect(container.querySelectorAll('.ant-descriptions-small')).toHaveLength(1);
|
|
|
|
});
|
2023-07-17 14:48:03 +08:00
|
|
|
|
|
|
|
it('should items work', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<Descriptions
|
|
|
|
items={[
|
|
|
|
{
|
|
|
|
key: '1',
|
|
|
|
label: 'UserName',
|
|
|
|
children: 'Zhou Maomao',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '2',
|
|
|
|
label: 'Telephone',
|
|
|
|
children: '1810000000',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '3',
|
|
|
|
label: 'Live',
|
|
|
|
children: 'Hangzhou, Zhejiang',
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
expect(container.querySelector('.ant-descriptions-item')).toBeTruthy();
|
|
|
|
expect(container.querySelectorAll('.ant-descriptions-item')).toHaveLength(3);
|
|
|
|
expect(container).toMatchSnapshot();
|
|
|
|
});
|
2023-08-10 14:06:13 +08:00
|
|
|
|
|
|
|
it('Descriptions nested within an Item are unaffected by the external borderless style', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<Descriptions bordered>
|
|
|
|
<Descriptions.Item>
|
|
|
|
<Descriptions bordered={false} />
|
|
|
|
</Descriptions.Item>
|
|
|
|
</Descriptions>,
|
|
|
|
);
|
|
|
|
|
2024-03-08 07:12:03 +08:00
|
|
|
const nestDesc = container.querySelectorAll('.ant-descriptions')[1];
|
2023-08-10 14:06:13 +08:00
|
|
|
const view = nestDesc.querySelector('.ant-descriptions-view');
|
|
|
|
expect(getComputedStyle(view!).border).toBeFalsy();
|
|
|
|
});
|
2023-08-17 21:12:10 +08:00
|
|
|
|
|
|
|
it('Should Descriptions not throw react key prop error in jsx mode', () => {
|
|
|
|
render(
|
|
|
|
<Descriptions title="User Info">
|
|
|
|
<Descriptions.Item key="1" label="UserName">
|
|
|
|
Zhou Maomao
|
|
|
|
</Descriptions.Item>
|
|
|
|
<Descriptions.Item label="Telephone">1810000000</Descriptions.Item>
|
|
|
|
</Descriptions>,
|
|
|
|
);
|
|
|
|
expect(errorSpy).not.toHaveBeenCalledWith(
|
|
|
|
expect.stringContaining('`key` is not a prop'),
|
|
|
|
expect.anything(),
|
|
|
|
expect.anything(),
|
|
|
|
);
|
|
|
|
});
|
2024-01-27 23:01:44 +08:00
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/47151
|
|
|
|
it('should has .ant-descriptions-item-content className when children is falsy', () => {
|
|
|
|
const wrapper = render(
|
|
|
|
<Descriptions
|
|
|
|
bordered
|
|
|
|
items={[
|
|
|
|
{
|
|
|
|
key: '1',
|
|
|
|
label: null,
|
|
|
|
children: null,
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>,
|
|
|
|
);
|
|
|
|
expect(wrapper.container.querySelectorAll('.ant-descriptions-item-label')).toHaveLength(1);
|
|
|
|
expect(wrapper.container.querySelectorAll('.ant-descriptions-item-content')).toHaveLength(1);
|
|
|
|
});
|
2019-05-22 23:22:09 +08:00
|
|
|
});
|