The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { ProjectId, SourceControlProviderKind } from "@t3tools/contracts"; |
| 2 | import { describe, expect, it } from "vite-plus/test"; |
| 3 | |
| 4 | import { pullRequestSyncKey } from "./pullRequestSyncKey.ts"; |
| 5 | |
| 6 | describe("pullRequestSyncKey", () => { |
| 7 | const reference = { projectId: ProjectId.make("project"), repository: "web", number: 7 }; |
| 8 | // Every spelling of the key reaches dev.azure.com through the definition's canonical key, |
| 9 | // which the Azure DevOps package tests. |
| 10 | it("resolves hostless and checkout-host references named by the bare repository", () => { |
| 11 | const canonicalKey = "ssh.dev.azure.com/v3/org/project/web"; |
| 12 | const identity = { |
| 13 | canonicalKey, |
| 14 | provider: SourceControlProviderKind.make("azure-devops"), |
| 15 | name: "web", |
| 16 | displayName: canonicalKey.split("/").slice(1).join("/"), |
| 17 | locator: { |
| 18 | source: "git-remote" as const, |
| 19 | remoteName: "origin", |
| 20 | remoteUrl: `https://${canonicalKey}`, |
| 21 | }, |
| 22 | }; |
| 23 | const expected = { host: "dev.azure.com", repository: "org/project/_git/web", number: 7 }; |
| 24 | expect(pullRequestSyncKey(reference, identity)).toEqual(expected); |
| 25 | expect( |
| 26 | pullRequestSyncKey({ ...reference, host: canonicalKey.split("/")[0]! }, identity), |
| 27 | ).toEqual(expected); |
| 28 | expect(pullRequestSyncKey({ ...reference, repository: "other" }, identity)).toBeNull(); |
| 29 | expect(pullRequestSyncKey({ ...reference, host: "unrelated.test" }, identity)).toBeNull(); |
| 30 | }); |
| 31 | it("normalizes complete hosted aliases without requiring a checkout", () => { |
| 32 | expect( |
| 33 | pullRequestSyncKey({ |
| 34 | ...reference, |
| 35 | host: "org.visualstudio.com", |
| 36 | repository: "project/_git/web", |
| 37 | }), |
| 38 | ).toEqual({ host: "dev.azure.com", repository: "org/project/_git/web", number: 7 }); |
| 39 | expect( |
| 40 | pullRequestSyncKey({ ...reference, host: "github.com", repository: "acme/web" }), |
| 41 | ).toEqual({ host: "github.com", repository: "acme/web", number: 7 }); |
| 42 | expect(pullRequestSyncKey(reference)).toBeNull(); |
| 43 | }); |
| 44 | }); |