-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.test.js
67 lines (62 loc) · 1.63 KB
/
server.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
61
62
63
64
65
66
67
const getMatchingDrinks = require("./server");
describe(getMatchingDrinks, () => {
it(" returns an empty array when ingredients are empty", async () => {
const result1 = await getMatchingDrinks([]);
expect(result1).toBe([]);
});
it(" returns an empty array when no matching cocktails are found", async () => {
const result2 = await getMatchingDrinks(["test"]);
expect(result2).toBe([]);
});
it(" returns the matching cocktails containing the ingredients", async () => {
const result3 = await getMatchingDrinks(["Sugar", "Lime juice"]);
expect(result3).toEqual([
{
id: "11064",
name: "Banana Daiquiri",
ingredients: [
"Light rum",
"Triple sec",
"Banana",
"Lime juice",
"Sugar",
"Cherry"
]
}
]);
});
it(" is insensitive to the order of ingredients", async () => {
const result = await getMatchingDrinks(["lime juice", "sugar"]);
expect(result).toEqual([
{
id: "11064",
name: "Banana Daiquiri",
ingredients: [
"Light rum",
"Triple sec",
"Banana",
"Lime juice",
"Sugar",
"Cherry"
]
}
]);
});
it(" is insensitive to case of search teams", async () => {
const result = await getMatchingDrinks(["lime juice", "SUGAR"]);
expect(result).toEqual([
{
id: "11064",
name: "Banana Daiquiri",
ingredients: [
"Light rum",
"Triple sec",
"Banana",
"Lime juice",
"Sugar",
"Cherry"
]
}
]);
});
});