-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsolution.spec.js
39 lines (36 loc) · 1018 Bytes
/
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
import { findNaughtyStep } from "./solution";
describe("Challenge #3: 😏 The Naughty Elf", () => {
const testCases = [
createTestCase(
["abcd", "abcde"],
"e",
"should return the first extra step added"
),
createTestCase(
["stepfor", "stepor"],
"f",
"should return the first extra step added"
),
createTestCase(
["abcde", "abcde"],
"",
"should return an empty string when sequences are identical"
),
createTestCase(
["", "a"],
"a",
"should return the first extra step added when the original sequence is empty"
),
createTestCase(
["a", ""],
"a",
"should return the first extra step added when the modified sequence is empty"
),
];
it.each(testCases)("#$# $description", ({ input, expected, description }) => {
expect(findNaughtyStep(...input)).toEqual(expected);
});
});
function createTestCase(input, expected, description) {
return { input, expected, description };
}