mirror of
https://github.com/ant-design/ant-design.git
synced 2025-08-06 07:56:28 +08:00
test: increase test case cov of List (#24510)
This commit is contained in:
parent
d5e7187d9d
commit
ef7e7a80d2
@ -128,4 +128,54 @@ describe('List Item Layout', () => {
|
|||||||
);
|
);
|
||||||
expect(render(wrapper)).toMatchSnapshot();
|
expect(render(wrapper)).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('rowKey could be string', () => {
|
||||||
|
const dataWithId = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
title: `ant design`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
title: `ant design`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
title: `ant design`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const wrapper = mount(
|
||||||
|
<List
|
||||||
|
dataSource={dataWithId}
|
||||||
|
rowKey="id"
|
||||||
|
renderItem={item => <List.Item>{item.title}</List.Item>}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rowKey could be function', () => {
|
||||||
|
const dataWithId = [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
title: `ant design`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
title: `ant design`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
title: `ant design`,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const wrapper = mount(
|
||||||
|
<List
|
||||||
|
dataSource={dataWithId}
|
||||||
|
rowKey={item => item.id}
|
||||||
|
renderItem={item => <List.Item>{item.title}</List.Item>}
|
||||||
|
/>,
|
||||||
|
);
|
||||||
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -57,6 +57,154 @@ exports[`List Item Layout horizontal itemLayout List should accept extra node 1`
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`List Item Layout rowKey could be function 1`] = `
|
||||||
|
<List
|
||||||
|
dataSource={
|
||||||
|
Array [
|
||||||
|
Object {
|
||||||
|
"id": 1,
|
||||||
|
"title": "ant design",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": 2,
|
||||||
|
"title": "ant design",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": 3,
|
||||||
|
"title": "ant design",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
renderItem={[Function]}
|
||||||
|
rowKey={[Function]}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="ant-list ant-list-split"
|
||||||
|
>
|
||||||
|
<Spin
|
||||||
|
size="default"
|
||||||
|
spinning={false}
|
||||||
|
wrapperClassName=""
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="ant-spin-nested-loading"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="ant-spin-container"
|
||||||
|
key="container"
|
||||||
|
>
|
||||||
|
<ul
|
||||||
|
className="ant-list-items"
|
||||||
|
>
|
||||||
|
<Item
|
||||||
|
key="1/.0"
|
||||||
|
>
|
||||||
|
<li
|
||||||
|
className="ant-list-item"
|
||||||
|
>
|
||||||
|
ant design
|
||||||
|
</li>
|
||||||
|
</Item>
|
||||||
|
<Item
|
||||||
|
key="2/.1"
|
||||||
|
>
|
||||||
|
<li
|
||||||
|
className="ant-list-item"
|
||||||
|
>
|
||||||
|
ant design
|
||||||
|
</li>
|
||||||
|
</Item>
|
||||||
|
<Item
|
||||||
|
key="3/.2"
|
||||||
|
>
|
||||||
|
<li
|
||||||
|
className="ant-list-item"
|
||||||
|
>
|
||||||
|
ant design
|
||||||
|
</li>
|
||||||
|
</Item>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Spin>
|
||||||
|
</div>
|
||||||
|
</List>
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`List Item Layout rowKey could be string 1`] = `
|
||||||
|
<List
|
||||||
|
dataSource={
|
||||||
|
Array [
|
||||||
|
Object {
|
||||||
|
"id": 1,
|
||||||
|
"title": "ant design",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": 2,
|
||||||
|
"title": "ant design",
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"id": 3,
|
||||||
|
"title": "ant design",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
renderItem={[Function]}
|
||||||
|
rowKey="id"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="ant-list ant-list-split"
|
||||||
|
>
|
||||||
|
<Spin
|
||||||
|
size="default"
|
||||||
|
spinning={false}
|
||||||
|
wrapperClassName=""
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="ant-spin-nested-loading"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className="ant-spin-container"
|
||||||
|
key="container"
|
||||||
|
>
|
||||||
|
<ul
|
||||||
|
className="ant-list-items"
|
||||||
|
>
|
||||||
|
<Item
|
||||||
|
key="1/.0"
|
||||||
|
>
|
||||||
|
<li
|
||||||
|
className="ant-list-item"
|
||||||
|
>
|
||||||
|
ant design
|
||||||
|
</li>
|
||||||
|
</Item>
|
||||||
|
<Item
|
||||||
|
key="2/.1"
|
||||||
|
>
|
||||||
|
<li
|
||||||
|
className="ant-list-item"
|
||||||
|
>
|
||||||
|
ant design
|
||||||
|
</li>
|
||||||
|
</Item>
|
||||||
|
<Item
|
||||||
|
key="3/.2"
|
||||||
|
>
|
||||||
|
<li
|
||||||
|
className="ant-list-item"
|
||||||
|
>
|
||||||
|
ant design
|
||||||
|
</li>
|
||||||
|
</Item>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Spin>
|
||||||
|
</div>
|
||||||
|
</List>
|
||||||
|
`;
|
||||||
|
|
||||||
exports[`List Item Layout should render in RTL direction 1`] = `
|
exports[`List Item Layout should render in RTL direction 1`] = `
|
||||||
<div
|
<div
|
||||||
class="ant-list ant-list-split ant-list-rtl"
|
class="ant-list ant-list-split ant-list-rtl"
|
||||||
|
Loading…
Reference in New Issue
Block a user