Skip to content

Commit 3151ec4

Browse files
committed
update test in sum.test.js to handle decimals using toBeClose
1 parent 0fd7113 commit 3151ec4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Sprint-1/implement/sum.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ test("given an array containing negative numbers, it returns the correct sum", (
3535
// When passed to the sum function
3636
// Then it should return the correct total sum
3737
test("given an array with decimal float numbers, it should return the total sum", () => {
38-
expect(sum([1.5, 2.5, 3.5])).toEqual(7.5);
38+
expect(sum([1.5, 2.5, 3.5])).toBeCloseTo(7.5);
3939
});
4040
// Given an array containing non-number values
4141
// When passed to the sum function
@@ -50,3 +50,5 @@ test("given an array containing non-number values, it should ignore the non-numb
5050
test("given an array with non-number values, returns Not a Number (NaN)", () => {
5151
expect(sum(["a", "b", "c"])).toBeNaN(); // note: NaN !== NaN,
5252
});
53+
54+
//

0 commit comments

Comments
 (0)