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);
});
}
});
添加回答
舉報