Challenge 1: Test a Pure Function — Possible Solution ==================================================================== // currency.ts function formatCurrency(amount: number): string { const sign = amount < 0 ? "-" : ""; const absolute = Math.abs(amount).toFixed(2); return `${sign}$${absolute}`; } export { formatCurrency }; // currency.test.ts import { formatCurrency } from "./currency"; describe("formatCurrency", () => { it("formats a whole number with two decimal places", () => { expect(formatCurrency(100)).toBe("$100.00"); }); it("formats zero correctly", () => { expect(formatCurrency(0)).toBe("$0.00"); }); it("formats negative numbers with a leading minus sign", () => { expect(formatCurrency(-42.5)).toBe("-$42.50"); }); it("rounds to two decimal places", () => { expect(formatCurrency(19.999)).toBe("$20.00"); }); it("formats large values without truncating digits", () => { expect(formatCurrency(1234567.89)).toBe("$1234567.89"); }); }); WHY THIS WORKS -------------- - Each `it()` covers one specific behavior (zero, negative, rounding, large values) rather than cramming multiple unrelated assertions into one test — when one fails, the test name alone tells you which case broke. - Testing a pure function needs no mocks at all: same input always produces the same output, which is exactly what makes it fast and reliable to test.