From 173ed9dd9fc27b8d05082532296ae3fc0bce3c6c Mon Sep 17 00:00:00 2001 From: tmdeveloper007 Date: Sat, 27 Jun 2026 07:33:11 +0000 Subject: [PATCH] test: add unit tests for anthropic.ts --- test/anthropic.test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 test/anthropic.test.ts diff --git a/test/anthropic.test.ts b/test/anthropic.test.ts new file mode 100644 index 000000000..f67d9b0be --- /dev/null +++ b/test/anthropic.test.ts @@ -0,0 +1,22 @@ +import { describe, it, expect } from "vitest"; +import { generateWeeklySummary } from "../src/lib/anthropic"; + +describe("anthropic", () => { + describe("generateWeeklySummary", () => { + it("returns null when ANTHROPIC_API_KEY is not set", async () => { + // The function checks ANTHROPIC_API_KEY and returns null if empty + const result = await generateWeeklySummary({ + commits: { current: 10, previous: 5, delta: 5, trend: "up" }, + prs: { + thisWeek: { opened: 3, merged: 2 }, + lastWeek: { opened: 1, merged: 1 }, + }, + streak: 7, + topRepo: "my-project", + activeDays: { thisWeek: 5, lastWeek: 3 }, + }); + // Without ANTHROPIC_API_KEY set, returns null + expect(result).toBeNull(); + }); + }); +});