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

openPullRequestLink.test.ts

40 lines1.1 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { findProjectOnChangeRequestHost } from "./openPullRequestLink";
4​
5describe("findProjectOnChangeRequestHost", () => {
6 const project = (id: string, identity: Record<string, unknown>) =>
7 ({ id, repositoryIdentity: identity }) as never;
8 const frontend = project("frontend", {
9 canonicalKey: "github.com/acme/frontend",
10 provider: "github",
11 owner: "acme",
12 name: "frontend",
13 });
14 const backend = project("backend", {
15 canonicalKey: "github.com/acme/backend",
16 provider: "github",
17 owner: "acme",
18 name: "backend",
19 });
20​
21 it("prefers the project checked out from the link's own repository", () => {
22 expect(
23 findProjectOnChangeRequestHost([frontend, backend], {
24 host: "github.com",
25 repository: "acme/backend",
26 number: 7,
27 }),
28 ).toBe(backend);
29 });
30​
31 it("lends any project on the host to a repository nobody has checked out", () => {
32 expect(
33 findProjectOnChangeRequestHost([frontend], {
34 host: "github.com",
35 repository: "acme/backend",
36 number: 7,
37 }),
38 ).toBe(frontend);
39 });
40});