|
6 | 6 | */ |
7 | 7 |
|
8 | 8 | import { describe, expect, test } from "bun:test"; |
9 | | -import { ok } from "neverthrow"; |
| 9 | +import { err, ok } from "neverthrow"; |
10 | 10 | import type { GitHubClient } from "../../src/github/api.js"; |
11 | 11 | import type { ListSection, SectionKey } from "../../src/schema.js"; |
| 12 | +import { sectionFailure } from "../../src/sections/contract/errors.js"; |
12 | 13 | import type { SectionModule } from "../../src/sections/contract/module.js"; |
13 | 14 | import { planContext, snapshotContext } from "../../src/sections/contract/plan.js"; |
14 | 15 | import { labelsSection } from "../../src/sections/labels/index.js"; |
@@ -581,19 +582,19 @@ describe("duplicate live identities", () => { |
581 | 582 | ); |
582 | 583 |
|
583 | 584 | test("the negative control: a snapshot that skips the guard fails the proof, and so does a refusal with extra text", async () => { |
584 | | - const [seed] = SEEDS.labels; |
| 585 | + // The snapshot path alone: with plan() out of the proof, no plan-side failure can satisfy either anchor. |
| 586 | + const seed: Seed = { ...SEEDS.labels[0], declared: undefined }; |
585 | 587 | const unguarded = { |
586 | 588 | ...labelsSection, |
587 | 589 | snapshot: async () => ok({ value: undefined, notes: [] }), |
588 | 590 | } as SectionModule; |
589 | | - await expect(proveRefused(unguarded, seed)).rejects.toThrow(); |
| 591 | + await expect(proveRefused(unguarded, seed)).rejects.toThrow(/expected a failure, got a value/); |
| 592 | + // The refusal arrives as a value, so only the message comparison can fail the proof. |
590 | 593 | const padded = { |
591 | 594 | ...labelsSection, |
592 | | - snapshot: async () => { |
593 | | - throw new Error(`${seed.refusal} (and more)`); |
594 | | - }, |
| 595 | + snapshot: async () => err(sectionFailure("live-duplicate", `${seed.refusal} (and more)`)), |
595 | 596 | } as SectionModule; |
596 | | - await expect(proveRefused(padded, seed)).rejects.toThrow(); |
| 597 | + await expect(proveRefused(padded, seed)).rejects.toThrow(/toEqual[\s\S]*\(and more\)/); |
597 | 598 | }); |
598 | 599 | }); |
599 | 600 |
|
|
0 commit comments