-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilter-api-data.test.js
60 lines (57 loc) · 1.04 KB
/
filter-api-data.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
describe("Filter API data", function () {
const apiData = [
{
id: 1,
description: "",
price: 0,
title: "",
},
{
price: 0,
tags: [],
},
{
id: 3,
price: 0,
title: "",
},
];
it("should filter all objects that contain the key id", function () {
chai.expect(filterApiData(apiData, ["id"])).to.eql([
{
id: 1,
description: "",
price: 0,
title: "",
},
{
id: 3,
price: 0,
title: "",
},
]);
});
it("should filter all objects with an id and price", function () {
chai.expect(filterApiData(apiData, ["id", "price"])).to.eql([
{
id: 1,
description: "",
price: 0,
title: "",
},
{
id: 3,
price: 0,
title: "",
},
]);
});
it("should filter all objects with an tags key", function () {
chai.expect(filterApiData(apiData, ["tags"])).to.eql([
{
price: 0,
tags: [],
},
]);
});
});