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

usePullRequestLinking.test.ts

23 lines1.1 KB

1import { describe, expect, it } from "vite-plus/test";
2​
3import { canLinkChangeRequest } from "./usePullRequestLinking";
4import { parseChangeRequestUrl } from "~/lib/openPullRequestLink";
5​
6describe("canLinkChangeRequest (#9435 / #9440)", () => {
7 const nonGitProject = { id: "scratch-project" } as never;
8 const link = parseChangeRequestUrl("https://github.com/pingdotgg/t3code/pull/15111")!;
9​
10 it("links a pasted pull request URL when the server tracks links on the thread, even with no matching project", () => {
11 expect(canLinkChangeRequest("multiple", [nonGitProject], link)).toBe(true);
12 expect(canLinkChangeRequest("multiple", [], link)).toBe(true);
13 });
14​
15 it("still requires a matching project in single-link mode, where the link needs a projectId", () => {
16 expect(canLinkChangeRequest("single", [nonGitProject], link)).toBe(false);
17 expect(canLinkChangeRequest("single", [], link)).toBe(false);
18 });
19​
20 it("never links when the environment does not support pull request linking", () => {
21 expect(canLinkChangeRequest("unsupported", [nonGitProject], link)).toBe(false);
22 });
23});