11const permutations = require ( "./permutations-solution" ) ;
22
33describe ( "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