@@ -34,15 +34,10 @@ const sum = require("./sum.js");
3434// When passed to the sum function
3535// Then it should return the least surprising value given how it behaves for all other inputs
3636
37- describe ( "sum" , ( ) => {
38- [
39- { input : [ "apple" , "banana" , 1 , 10 ] , expected : 11 } ,
40- { input : [ 1 , - 1 , - 100 ] , expected : - 100 } ,
41- { input : [ - 10 , - 20 , - 3 , - 4 ] , expected : - 37 } ,
42- { input : [ 1.5 , 10.5 , 0.5 ] , expected : 12.5 } ,
43- { input : [ "apple" , "banana" , "cherry" ] , expected : - Infinity } ,
44- ] . forEach ( ( { input, expected } ) =>
45- it ( `returns the sum for [${ input } ]` , ( ) =>
46- expect ( sum ( input ) ) . toEqual ( expected ) )
47- ) ;
37+ test ( `Should return the correct sum of values` , ( ) => {
38+ expect ( sum ( [ "apple" , "banana" , 1 , 10 ] ) ) . toEqual ( 11 ) ;
39+ expect ( sum ( [ 1 , - 1 , - 100 ] ) ) . toEqual ( - 100 ) ;
40+ expect ( sum ( [ - 10 , - 20 , - 3 , - 4 ] ) ) . toEqual ( - 37 ) ;
41+ expect ( sum ( [ 1.5 , 10.5 , 0.5 ] ) ) . toBeCloseTo ( 12.5 ) ;
42+ expect ( sum ( [ "apple" , "banana" , "cherry" ] ) ) . toEqual ( - Infinity ) ;
4843} ) ;
0 commit comments