diff --git a/tests/unit/mathService.test.ts b/tests/unit/mathService.test.ts index 6967a33..eac781c 100644 --- a/tests/unit/mathService.test.ts +++ b/tests/unit/mathService.test.ts @@ -9,4 +9,11 @@ describe("Math Service - add", () => { const result = math.add(1, 2) expect(result).toBe(3) }) + + it("should throw an error if any of the arguments is not a number", () => { + expect(() => math.add(1, "2" as any)).toThrow("Both arguments must be numbers") + expect(() => math.add("1" as any, 2)).toThrow("Both arguments must be numbers") + expect(() => math.add("1" as any, "2" as any)).toThrow("Both arguments must be numbers") + expect(() => math.add(1, null as any)).toThrow("Both arguments must be numbers") + }) })