Skip to content

Commit fc19279

Browse files
committed
feat(permutations): copy over tests from solution
1 parent b5d77fa commit fc19279

File tree

1 file changed

+58
-9
lines changed

1 file changed

+58
-9
lines changed
Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,64 @@
1-
const permutations = require('./permutations');
1+
const permutations = require("./permutations");
22

3-
describe('permutations', () => {
4-
test('First test description', () => {
5-
// Replace this comment with any other necessary code, and update the expect line as necessary
3+
describe("permutations", () => {
4+
test("1 possible permutation for a set containing 0 numbers", () => {
5+
expect(permutations([]).sort()).toEqual([[]].sort());
6+
});
7+
8+
test.skip("1 possible permutation for a set containing 1 number", () => {
9+
expect(permutations([1]).sort()).toEqual([[1]].sort());
10+
});
11+
12+
test.skip("2 possible permutations for a set containing 2 numbers", () => {
13+
expect(permutations([1, 2]).sort()).toEqual(
14+
[
15+
[1, 2],
16+
[2, 1],
17+
].sort(),
18+
);
19+
});
620

7-
expect(permutations()).toBe('');
21+
test.skip("6 possible permutations for a set containing 3 numbers", () => {
22+
expect(permutations([1, 2, 3]).sort()).toEqual(
23+
[
24+
[1, 2, 3],
25+
[1, 3, 2],
26+
[2, 1, 3],
27+
[2, 3, 1],
28+
[3, 1, 2],
29+
[3, 2, 1],
30+
].sort(),
31+
);
832
});
9-
10-
test.skip('Second test description', () => {
11-
// Replace this comment with any other necessary code, and update the expect line as necessary
1233

13-
expect(permutations()).toBe('');
34+
test.skip("24 possible permutations for a set containing 4 numbers", () => {
35+
expect(permutations([1, 2, 3, 4]).sort()).toEqual(
36+
[
37+
[1, 2, 3, 4],
38+
[1, 2, 4, 3],
39+
[1, 3, 2, 4],
40+
[1, 3, 4, 2],
41+
[1, 4, 2, 3],
42+
[1, 4, 3, 2],
43+
[2, 1, 3, 4],
44+
[2, 1, 4, 3],
45+
[2, 3, 1, 4],
46+
[2, 3, 4, 1],
47+
[2, 4, 1, 3],
48+
[2, 4, 3, 1],
49+
[3, 1, 2, 4],
50+
[3, 1, 4, 2],
51+
[3, 2, 1, 4],
52+
[3, 2, 4, 1],
53+
[3, 4, 1, 2],
54+
[3, 4, 2, 1],
55+
[4, 1, 2, 3],
56+
[4, 1, 3, 2],
57+
[4, 2, 1, 3],
58+
[4, 2, 3, 1],
59+
[4, 3, 1, 2],
60+
[4, 3, 2, 1],
61+
].sort(),
62+
);
1463
});
1564
});

0 commit comments

Comments
 (0)