Skip to content

Commit ef5b1cd

Browse files
committed
feat(permutations): add test for an array containing no elements
1 parent 1831d39 commit ef5b1cd

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

16_permutations/solution/permutations-solution.spec.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
const permutations = require("./permutations-solution");
22

33
describe("permutations", () => {
4-
test("Works for array of size one", () => {
5-
expect(permutations([1]).sort()).toEqual([1].sort());
4+
test("1 possible permutation for a set containing 0 numbers", () => {
5+
expect(permutations([]).sort()).toEqual([[]].sort());
66
});
7-
test("Works for array of size two", () => {
7+
test("1 possible permutation for a set containing 1 number", () => {
8+
expect(permutations([1]).sort()).toEqual([[1]].sort());
9+
});
10+
test("2 possible permutations for a set containing 2 numbers", () => {
811
expect(permutations([1, 2]).sort()).toEqual(
912
[
1013
[1, 2],
1114
[2, 1],
1215
].sort(),
1316
);
1417
});
15-
test("Works for array of size three", () => {
18+
test("6 possible permutations for a set containing 3 numbers", () => {
1619
expect(permutations([1, 2, 3]).sort()).toEqual(
1720
[
1821
[1, 2, 3],
@@ -24,7 +27,7 @@ describe("permutations", () => {
2427
].sort(),
2528
);
2629
});
27-
test("Works for array of size four", () => {
30+
test("24 possible permutations for a set containing 4 numbers", () => {
2831
expect(permutations([1, 2, 3, 4]).sort()).toEqual(
2932
[
3033
[1, 2, 3, 4],

0 commit comments

Comments
 (0)