Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

issueTrackers.test.ts

36 lines1.3 KB

1import { IssueTrackerKind, MAX_ISSUE_TRACKER_ADDITIONAL_SCOPES } from "@t3tools/contracts";
2import { describe, expect, it } from "vite-plus/test";
3​
4import { issueTrackerScopeOptions } from "./issueTrackers.ts";
5​
6describe("issueTrackerScopeOptions", () => {
7 it("offers no new team once the binding is full, and keeps bound ones removable", () => {
8 const tracker = {
9 tracker: IssueTrackerKind.make("linear"),
10 displayName: "Linear",
11 host: "linear.app",
12 scopeNoun: "team",
13 credential: { label: "Personal API key", helpUrl: null },
14 connected: true,
15 account: "demo",
16 detail: null,
17 scopes: [
18 { key: "ENG", name: "Engineering" },
19 { key: "OPS", name: "Operations" },
20 ],
21 };
22 const full = [
23 "ENG",
24 ...Array.from({ length: MAX_ISSUE_TRACKER_ADDITIONAL_SCOPES }, (_, i) => `T${i}`),
25 ];
26 const options = issueTrackerScopeOptions(tracker, full);
27 expect(options.find((scope) => scope.key === "OPS")?.addable).toBe(false);
28 expect(options.find((scope) => scope.key === "ENG")?.addable).toBe(true);
29 expect(options.find((scope) => scope.key === "T0")).toEqual({
30 key: "T0",
31 name: "T0",
32 addable: true,
33 });
34 expect(issueTrackerScopeOptions(tracker, ["ENG"]).every((scope) => scope.addable)).toBe(true);
35 });
36});