-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsolution.spec.js
39 lines (36 loc) · 1.01 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
import { decode } from "./solution";
describe("Challenge #4: 😵💫 Reverse the Parentheses", () => {
const testCases = [
createTestCase(
["hola (odnum)"],
"hola mundo",
"should reverse characters inside parentheses"
),
createTestCase(
["(olleh) (dlrow)!"],
"hello world!",
"should reverse characters inside parentheses, multiple occurrences"
),
createTestCase(
["sa(u(cla)atn)s"],
"santaclaus",
"should handle nested parentheses"
),
createTestCase(
[""],
"",
"should return an empty string when the input is an empty string"
),
createTestCase(
["abcde (12345)"],
"edcba 54321",
"should reverse characters inside parentheses, alphanumeric content"
),
];
it.each(testCases)("#$# $description", ({ input, expected, description }) => {
expect(decode(...input)).toEqual(expected);
});
});
function createTestCase(input, expected, description) {
return { input, expected, description };
}