|
1 | | -const permutations = require('./permutations'); |
| 1 | +const permutations = require("./permutations"); |
2 | 2 |
|
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 | + }); |
6 | 20 |
|
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 | + ); |
8 | 32 | }); |
9 | | - |
10 | | - test.skip('Second test description', () => { |
11 | | - // Replace this comment with any other necessary code, and update the expect line as necessary |
12 | 33 |
|
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 | + ); |
14 | 63 | }); |
15 | 64 | }); |
0 commit comments