Blame · Line-by-line history
spec-to-pr.test.ts
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 14c3cc8 | 1 | import { describe, it, expect, afterEach } from "bun:test"; |
| 2 | import { createSpecPR } from "../lib/spec-to-pr"; | |
| 3 | ||
| 4 | describe("createSpecPR", () => { | |
| 5 | const originalKey = process.env.ANTHROPIC_API_KEY; | |
| 6 | ||
| 7 | afterEach(() => { | |
| 8 | if (originalKey === undefined) delete process.env.ANTHROPIC_API_KEY; | |
| 9 | else process.env.ANTHROPIC_API_KEY = originalKey; | |
| 10 | }); | |
| 11 | ||
| 12 | it("returns ok:false when ANTHROPIC_API_KEY is missing", async () => { | |
| 13 | delete process.env.ANTHROPIC_API_KEY; | |
| 14 | const result = await createSpecPR({ repoId: 1, spec: "test", userId: 1 }); | |
| 15 | expect(result.ok).toBe(false); | |
| 16 | expect(result.error).toContain("ANTHROPIC_API_KEY"); | |
| 17 | }); | |
| 18 | ||
| 19 | it("returns ok:false with a clear experimental notice when key is set", async () => { | |
| 20 | process.env.ANTHROPIC_API_KEY = "fake-key-for-testing"; | |
| 21 | const result = await createSpecPR({ repoId: -999, spec: "test", userId: 1 }); | |
| 22 | expect(result.ok).toBe(false); | |
| 23 | expect(result.error).toBeTruthy(); | |
| 24 | }); | |
| 25 | }); |