Skip to content
Myr

recent-landing.test.ts

This file

Path

packages/protocol/test/recent-landing.test.ts

51 lines · 1.6 KiB · TypeScript

Last changed by

Merge redesign into mainoscabrielbefore adoptioncaedd21

History of this file

Take it

Merge redesign into mainoscabrielbefore adoptioncaedd21

lines 1–51why, one step back
1import { describe, expect, it } from "@effect/vitest";
2import { Schema } from "effect";34import { ShownRefusal, shownRefusal } from "../src/domain/recent-landing.ts";5import { RepoPath } from "../src/ids.ts";6import {7 ChecksFailed,8 HeldBackFailed,9 OutOfScope,10 SecretInOutput,11} from "../src/refusal.ts";12import type { Refusal } from "../src/refusal.ts";13import { examples } from "./examples.ts";1415describe(shownRefusal, () => {16 it("shows a held-back check's area and never its suite", () => {17 expect(18 shownRefusal(new HeldBackFailed({ area: "parser", suite: "edge-cases" }))19 ).toStrictEqual({ area: "parser", tag: "HeldBackFailed" });20 });2122 it("shows a failed lane, a path or a secret's name by its tag alone", () => {23 expect([24 shownRefusal(25 new ChecksFailed({ lane: "unit", logRef: "logs/7", next: "bun test" })26 ),27 shownRefusal(new OutOfScope({ paths: [RepoPath.make("src/secret.ts")] })),28 shownRefusal(29 new SecretInOutput({ item: "PAYMENTS_KEY", where: "output" })30 ),31 ]).toStrictEqual([32 { tag: "ChecksFailed" },33 { tag: "OutOfScope" },34 { tag: "SecretInOutput" },35 ]);36 });3738 it("shows every refusal of the union as no more than a tag and an area", () => {39 const fields = new Set(40 examples.flatMap((refusal: Refusal) => Object.keys(shownRefusal(refusal)))41 );4243 expect(fields).toStrictEqual(new Set(["area", "tag"]));44 });4546 it("refuses a tag the union does not have", () => {47 expect(48 Schema.decodeUnknownOption(ShownRefusal)({ tag: "SomethingElse" })._tag49 ).toBe("None");50 });51});