@@ -43,16 +43,7 @@ test("given an array containing negative numbers, it returns the correct total s
4343test ( "given an array with decimal numbers, it returns the correct total sum" , ( ) => {
4444 const input = [ 1.5 , 2.3 , 0.7 ] ;
4545 const expectedOutput = 4.5 ;
46- expect ( sum ( input ) ) . toBe ( expectedOutput ) ;
47- } ) ;
48-
49- // Given an array with decimal/float numbers
50- // When passed to the sum function
51- // Then it should return the correct total sum
52- test ( "given an array with decimal numbers, it returns the correct total sum" , ( ) => {
53- const input = [ 1.5 , 2.3 , 0.7 ] ;
54- const expectedOutput = 4.5 ;
55- expect ( sum ( input ) ) . toBe ( expectedOutput ) ;
46+ expect ( sum ( input ) ) . toBeCloseTo ( expectedOutput ) ;
5647} ) ;
5748
5849// Given an array containing non-number values
@@ -64,15 +55,6 @@ test("given an array containing non-number values, it ignores them and returns t
6455 expect ( sum ( input ) ) . toBe ( expectedOutput ) ;
6556} ) ;
6657
67- // Given an array containing non-number values
68- // When passed to the sum function
69- // Then it should ignore the non-numerical values and return the sum of the numerical elements
70- test ( "given an array containing non-number values, it ignores them and returns the sum of the numerical elements" , ( ) => {
71- const input = [ "hello" , "world" ] ;
72- const expectedOutput = 0 ;
73- expect ( sum ( input ) ) . toBe ( expectedOutput ) ;
74- } ) ;
75-
7658// Given an array with only non-number values
7759// When passed to the sum function
7860// Then it should return the least surprising value given how it behaves for all other inputs
0 commit comments