Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/unit/mathService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should add another test that checks when the first argument is null

})
})