import { expect, test } from "vitest" import { sum } from "#Source/calc/sum.ts" test("sum adds all numbers in the array", () => { expect(sum([1, 2, 3])).toBe(6) expect(sum([-1, 0, 1])).toBe(0) expect(sum([])).toBe(0) }) test("sum throws when the array contains non-number values", () => { expect(() => sum([1, "2" as unknown as number, 3])).toThrow( "All elements in the array must be numbers.", ) expect(() => sum([undefined as unknown as number])).toThrow( "All elements in the array must be numbers.", ) })