1import { describe, expect, it } from "vite-plus/test";
2
3import { sourceControlClients } from "./sourceControlClients.ts";
4
5describe("sourceControlClients", () => {
6 it("reads a missing kind as the first host and an unshipped kind as the generic one", () => {
7 expect(sourceControlClients.get(undefined).kind).toBe("github");
8 expect(sourceControlClients.get("forkhost").kind).toBe("unknown");
9 });
10
11 it("gives a change request URL to the first host whose shape it has", () => {
12 // GitCafe and Forgejo share `/pulls/`; GitCafe only claims its own hostnames.
13 const kindOf = (url: string) => sourceControlClients.findByChangeRequestUrl(url)?.kind;
14 expect(kindOf("https://git.cafe/acme/web/pulls/7")).toBe("gitcafe");
15 expect(kindOf("https://codeberg.org/acme/web/pulls/7")).toBe("forgejo");
16 });
17});