我有一个使用antd Table显示数据的简单组件。我想通过在表列上测试onFilter函数和sorter函数来模拟测试中的用户操作。关于如何测试此组件的任何想法吗?我想在测试中模拟对onFilter的调用(“蚂蚁表”列)。
要测试的组件:
.
.
.
private columns = [
{
title: 'Name',
dataIndex: 'name',
filters: this.state.names,
onFilter: (value, record) => record.name.indexOf(value) === 0,
sorter: (a, b) => a.name > b.name,
sortDirections: ['descend']
},
{
title: 'Address',
dataIndex: 'address',
filters: this.state.addresses,
onFilter: (value, record) => record. address.indexOf(value) === 0,
sorter: (a, b) => a.address'> b.address,
sortDirections: ['descend']
}
]
public render() {
return (
<Table
columns={this.columns}
dataSource={this.state.data}
/>
);
}
.
.
.