The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import { ProjectId } from "@t3tools/contracts"; |
| 2 | import { describe, expect, it } from "vite-plus/test"; |
| 3 | |
| 4 | import { pullRequestCandidateForIssueLink } from "./pullRequestNavigation"; |
| 5 | |
| 6 | const ref = { projectId: ProjectId.make("project-1"), host: "github.com", scope: "acme/app" }; |
| 7 | |
| 8 | describe("pullRequestCandidateForIssueLink", () => { |
| 9 | it("offers a pull request only where the host numbers issues and pull requests together", () => { |
| 10 | expect( |
| 11 | pullRequestCandidateForIssueLink("https://github.com/acme/app/issues/12", { |
| 12 | ...ref, |
| 13 | key: "12", |
| 14 | }), |
| 15 | ).toEqual({ |
| 16 | target: { projectId: "project-1", host: "github.com", repository: "acme/app", number: 12 }, |
| 17 | navigationUrl: undefined, |
| 18 | }); |
| 19 | expect( |
| 20 | pullRequestCandidateForIssueLink("https://gitlab.com/acme/app/-/issues/12", { |
| 21 | ...ref, |
| 22 | host: "gitlab.com", |
| 23 | key: "12", |
| 24 | }), |
| 25 | ).toBeNull(); |
| 26 | expect( |
| 27 | pullRequestCandidateForIssueLink("https://dev.azure.com/acme/app/_workitems/edit/12", { |
| 28 | ...ref, |
| 29 | host: "dev.azure.com", |
| 30 | key: "12", |
| 31 | }), |
| 32 | ).toBeNull(); |
| 33 | }); |
| 34 | |
| 35 | it("keeps a comment anchor for the pull request screen to scroll to", () => { |
| 36 | expect( |
| 37 | pullRequestCandidateForIssueLink("https://github.com/acme/app/issues/12#issuecomment-345", { |
| 38 | ...ref, |
| 39 | key: "12", |
| 40 | })?.navigationUrl, |
| 41 | ).toBe("https://github.com/acme/app/pull/12#issuecomment-345"); |
| 42 | }); |
| 43 | }); |