Skip to content

Commit c4a0488

Browse files
committed
added tests that throw error when the argument is non array
1 parent 12e8cb0 commit c4a0488

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎Sprint-1/implement/sum.test.js‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test("should return the number when given negative numbers ", () => {
3838
// When passed to the sum function
3939
// Then it should return the correct total sum
4040
test("should return the number when given decimal number", () => {
41-
expect(sum([2.5, 3.4, 5.7, 2])).toEqual(13.6);
41+
expect(sum([2.5, 3.4, 5.5, 2])).toEqual(13.4);
4242
expect(sum([1, 1.5, 2.5, 6.3])).toEqual(11.3);
4343
expect(sum([2.3, 2.7, 7.4, 5.5])).toEqual(17.9);
4444
});
@@ -55,3 +55,12 @@ test("should throw an error when argument is passed that is non number", () => {
5555
// Given something that isn't an array at all, such as "hey", 42 or no argument
5656
// When passed to the sum function
5757
// Then it should throw Error("sum requires an array of numbers")
58+
test("should throw an error when argument 'hey'is passed", () => {
59+
expect(() => sum("hey")).toThrow("sum requires an array of numbers");
60+
});
61+
test("should throw an error when argument 42 is passed", () => {
62+
expect(() => sum(42)).toThrow("sum requires an array of numbers");
63+
});
64+
test("should throw an error when no argument is passed", () => {
65+
expect(() => sum()).toThrow("sum requires an array of numbers");
66+
});

0 commit comments

Comments
 (0)