@@ -21,14 +21,16 @@ describe("calculateMedian", () => {
21
21
{ input : [ 5 , 1 , 3 , 4 , 2 ] , expected : 3 } ,
22
22
{ input : [ 4 , 2 , 1 , 3 ] , expected : 2.5 } ,
23
23
{ input : [ 6 , 1 , 5 , 3 , 2 , 4 ] , expected : 3.5 } ,
24
+ { input : [ 110 , 20 , 0 ] , expected : 20 } ,
25
+ { input : [ 6 , - 2 , 2 , 12 , 14 ] , expected : 6 } ,
24
26
] . forEach ( ( { input, expected } ) =>
25
27
it ( `returns the correct median for unsorted array [${ input } ]` , ( ) => expect ( calculateMedian ( input ) ) . toEqual ( expected ) )
26
28
) ;
27
29
28
- it ( "doesn't modify the input array [1, 2, 3 ]" , ( ) => {
29
- const list = [ 1 , 2 , 3 ] ;
30
+ it ( "doesn't modify the input array [3, 1, 2 ]" , ( ) => {
31
+ const list = [ 3 , 1 , 2 ] ;
30
32
calculateMedian ( list ) ;
31
- expect ( list ) . toEqual ( [ 1 , 2 , 3 ] ) ;
33
+ expect ( list ) . toEqual ( [ 3 , 1 , 2 ] ) ;
32
34
} ) ;
33
35
34
36
[ 'not an array' , 123 , null , undefined , { } , [ ] , [ "apple" , null , undefined ] ] . forEach ( val =>
@@ -45,4 +47,4 @@ describe("calculateMedian", () => {
45
47
] . forEach ( ( { input, expected } ) =>
46
48
it ( `filters out non-numeric values and calculates the median for [${ input } ]` , ( ) => expect ( calculateMedian ( input ) ) . toEqual ( expected ) )
47
49
) ;
48
- } ) ;
50
+ } ) ;
0 commit comments