-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsolution.spec.js
53 lines (50 loc) · 1.27 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
45
46
47
48
49
50
51
52
53
import { cyberReindeer } from "./solution";
describe("Challenge #5: 🛷 Santa's CyberTruck", () => {
const testCases = [
createTestCase(
["S..|...|..", 10],
[
"S..|...|..",
".S.|...|..",
"..S|...|..",
"..S|...|..",
"..S|...|..",
"...S...*..",
"...*S..*..",
"...*.S.*..",
"...*..S*..",
"...*...S..",
],
"should simulate sled's movement for a given time"
),
createTestCase(
["|..|", 3],
["|..|", "*..|", ".*.|"],
"should simulate sled's movement for a given time with closed barriers"
),
createTestCase(
["S..|...|..", 1],
["S..|...|.."],
"should return the initial state when time is 1"
),
createTestCase(
["....|....", 7],
[
"....|....",
"....|....",
"....|....",
"....|....",
"....|....",
"....|....",
"....|....",
],
"should simulate sled's movement for a given time with no barriers"
),
];
it.each(testCases)("#$# $description", ({ input, expected, description }) => {
expect(cyberReindeer(...input)).toEqual(expected);
});
});
function createTestCase(input, expected, description) {
return { input, expected, description };
}