-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchallenge18.spec.js
56 lines (53 loc) · 1.57 KB
/
challenge18.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
45
46
47
48
49
50
51
52
53
54
55
56
const findInAgenda = require("./challenge18");
describe("Challenge 18 Tests", () => {
const TEST_CASES = [
{
input: [
"+34-600-123-456 Calle Gran Via 12 <Juan Perez>\n" +
"Plaza Mayor 45 Madrid 28013 <Maria Gomez> +34-600-987-654\n" +
"<Carlos Ruiz> +1-800-555-0199 Fifth Ave New York",
"34-600-123-456"
],
output: {
"name": "Juan Perez",
"address": "Calle Gran Via 12"
}
},
{
input: [
"+34-600-123-456 Calle Gran Via 12 <Juan Perez>\n" +
"Plaza Mayor 45 Madrid 28013 <Maria Gomez> +34-600-987-654\n" +
"<Carlos Ruiz> +1-800-555-0199 Fifth Ave New York",
"600-987"
],
output: {
"name": "Maria Gomez",
"address": "Plaza Mayor 45 Madrid 28013"
}
},
{
input: [
"+34-600-123-456 Calle Gran Via 12 <Juan Perez>\n" +
"Plaza Mayor 45 Madrid 28013 <Maria Gomez> +34-600-987-654\n" +
"<Carlos Ruiz> +1-800-555-0199 Fifth Ave New York",
"111"
],
output: null
},
{
input: [
"+34-600-123-456 Calle Gran Via 12 <Juan Perez>\n" +
"Plaza Mayor 45 Madrid 28013 <Maria Gomez> +34-600-987-654\n" +
"<Carlos Ruiz> +1-800-555-0199 Fifth Ave New York",
"1"
],
output: null
},
];
it("Should return an object", () => {
expect(typeof findInAgenda(...TEST_CASES[0].input)).toBe(typeof {});
});
it.each(TEST_CASES)("Should pass the test cases successfully", ({ input, output }) => {
expect(findInAgenda(...input)).toEqual(output);
});
});