1 回答

TA贡献1859条经验 获得超6个赞
正如我们所讨论的,我添加了用于按名称检查过滤器和排序的测试用例。对于排序,您可以使用 chai-sorting 包:npm install chai-sorted. 您需要根据下面的评论对代码进行一些调整。希望它会有所帮助
it('searches for record and sort', async () => {
const search_key = "Rajesh";
const limit = 25;
//you will need to have `data` variable and link `search_key` and `limit` with it somehow
const people = await search_data()(data);
if (people) {
//length must be less than or equal to `limit`
expect(people.length).to.be.at.most(limit);
// check sorting by name. you can change it as descendingBy if you need
expect(people).to.be.ascendingBy("name");
people.forEach(person => {
//checking filter for name
expect(person.name).to.have.string(search_key);
});
}
});
添加回答
举报