@@ -21,14 +21,16 @@ describe("calculateMedian", () => {
2121 { input : [ 5 , 1 , 3 , 4 , 2 ] , expected : 3 } ,
2222 { input : [ 4 , 2 , 1 , 3 ] , expected : 2.5 } ,
2323 { 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 } ,
2426 ] . forEach ( ( { input, expected } ) =>
2527 it ( `returns the correct median for unsorted array [${ input } ]` , ( ) => expect ( calculateMedian ( input ) ) . toEqual ( expected ) )
2628 ) ;
2729
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 ] ;
3032 calculateMedian ( list ) ;
31- expect ( list ) . toEqual ( [ 1 , 2 , 3 ] ) ;
33+ expect ( list ) . toEqual ( [ 3 , 1 , 2 ] ) ;
3234 } ) ;
3335
3436 [ 'not an array' , 123 , null , undefined , { } , [ ] , [ "apple" , null , undefined ] ] . forEach ( val =>
@@ -45,4 +47,4 @@ describe("calculateMedian", () => {
4547 ] . forEach ( ( { input, expected } ) =>
4648 it ( `filters out non-numeric values and calculates the median for [${ input } ]` , ( ) => expect ( calculateMedian ( input ) ) . toEqual ( expected ) )
4749 ) ;
48- } ) ;
50+ } ) ;
0 commit comments