From 0daa0d3607dca1ec1f6977eea17a622a482ae133 Mon Sep 17 00:00:00 2001 From: eric891224 Date: Sun, 6 Apr 2025 22:29:28 +0800 Subject: [PATCH] add second test --- tests/unit/mathService.test.ts | 7 +++++++ 1 file changed, 7 insertions(+) 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") + }) })