Skip to content
30 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import type { CardAction } from "@g1t/contracts";
5
6import { cardChip, foldsBody, shownActions } from "./card-actions.ts";
7
8test("a card shows only its links: nothing answers the rest any more", () => {
9 const actions: CardAction[] = [
10 { id: "file", label: "File issue" },
11 { id: "open", label: "Open", href: "/acme/web/issues/1" },
12 ];
13 assert.deepEqual(shownActions({ actions }).map((a) => a.id), ["open"]);
14 assert.deepEqual(shownActions({}), []);
15});
16
17test("a draft issue's chip says where it is", () => {
18 assert.deepEqual(cardChip({ kind: "draft_issue", state: "Draft" }), { tone: "accent", live: false, outline: true });
19 assert.equal(cardChip({ kind: "draft_issue", state: "Filed" })?.tone, "success");
20 assert.equal(cardChip({ kind: "draft_issue", state: "Discarded" })?.tone, "neutral");
21 assert.equal(cardChip({ kind: "draft_issue", state: "Something new" })?.tone, "neutral");
22 assert.equal(cardChip({ kind: "draft_issue", state: null }), null);
23 assert.equal(cardChip({ kind: "pull", state: "Merged" }), null);
24});
25
26test("a long body starts folded", () => {
27 assert.equal(foldsBody("one\ntwo\nthree"), false);
28 assert.equal(foldsBody(Array.from({ length: 12 }, () => "line").join("\n")), true);
29 assert.equal(foldsBody("x".repeat(900)), true);
30});