test: increase test case cov of List (#24510)

This commit is contained in:
偏右 2020-05-27 22:16:35 +08:00 committed by GitHub
parent d5e7187d9d
commit ef7e7a80d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 198 additions and 0 deletions

View File

@ -128,4 +128,54 @@ describe('List Item Layout', () => {
);
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();
});
});

View File

@ -57,6 +57,154 @@ exports[`List Item Layout horizontal itemLayout List should accept extra node 1`
</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`] = `
<div
class="ant-list ant-list-split ant-list-rtl"