-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsolution.spec.js
44 lines (41 loc) · 1.23 KB
/
solution.spec.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
import { manufacture } from "./solution";
describe("Challenge #2: 🏭 Factory in Action!", () => {
const testCases = [
createTestCase(
[["tren", "oso", "pelota"], "tronesa"],
["tren", "oso"],
"should return gifts that can be manufactured"
),
createTestCase(
[["juego", "puzzle"], "jlepuz"],
["puzzle"],
"should return gifts that can be manufactured"
),
createTestCase(
[["libro", "ps5"], "psli"],
[],
"should return an empty array when no gifts can be manufactured"
),
createTestCase(
[["calcetin", "sueter", "gorro"], "saetr"],
["calcetin", "sueter", "gorro"],
"should return all gifts when all can be manufactured"
),
createTestCase(
[[], "abc"],
[],
"should return an empty array when no gifts are given"
),
createTestCase(
[["robot", "laptop", "helicoptero"], "abc"],
[],
"should return an empty array when no gifts can be manufactured"
),
];
it.each(testCases)("#$# $description", ({ input, expected, description }) => {
expect(manufacture(...input)).toEqual(expected);
});
});
function createTestCase(input, expected, description) {
return { input, expected, description };
}