-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsolution.spec.js
44 lines (41 loc) · 1.14 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 { getIndexsForPalindrome } from "./solution";
describe("Challenge #11: 📖 The Studious Elves", () => {
const testCases = [
createTestCase(
["anna"],
[],
"should return an empty array for an input that is already a palindrome"
),
createTestCase(
["abab"],
[0, 1],
"should return the indices for a single swap palindrome"
),
createTestCase(
["abac"],
null,
"should return null for an input where no palindrome can be formed"
),
createTestCase(
["aaaaaaaa"],
[],
"should return an empty array for a string of the same characters"
),
createTestCase(
["aaababa"],
[1, 3],
"should return the indices for a single swap palindrome"
),
createTestCase(
["caababa"],
null,
"should return null for an input where no palindrome can be formed"
),
];
it.each(testCases)("#$# $description", ({ input, expected, description }) => {
expect(getIndexsForPalindrome(...input)).toEqual(expected);
});
});
function createTestCase(input, expected, description) {
return { input, expected, description };
}