Skip to content

Commit 58bc16c

Browse files
committed
test: add cases to verify calculateMean throws errors for invalid inputs
1 parent 9ea6b81 commit 58bc16c

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ test("throws for an empty array", () => {
4040
new Error("calculateMean requires a non-empty array")
4141
);
4242
});
43+
44+
test("throws when not given an array", () => {
45+
expect(() => calculateMean("banana")).toThrow(
46+
new Error("calculateMean requires an array of numbers")
47+
);
48+
});
49+
50+
test("throws for an array containing. a non-number", () => {
51+
expect(() => calculateMean([1, "2", 3])).toThrow(
52+
new Error("calculateMean requires a array of numbers")
53+
);
54+
});
4355
// Given an array with a single number
4456
// When passed to calculateMean
4557
// Then it should return that number

0 commit comments

Comments
 (0)