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 * as Result from "effect/Result"; |
| 2 | import { expect, it } from "vite-plus/test"; |
| 3 | |
| 4 | import { decodeGitHubPullRequestListJson } from "./gitHubPullRequests.ts"; |
| 5 | |
| 6 | // gh before 2.47 names the head repository without its owner, and a fork's checkout needs both. |
| 7 | it("names a fork's head repository from its owner when gh leaves nameWithOwner out", () => { |
| 8 | const decoded = decodeGitHubPullRequestListJson( |
| 9 | JSON.stringify([ |
| 10 | { |
| 11 | number: 642, |
| 12 | title: "fix: use commit as the default git action without origin", |
| 13 | url: "https://github.com/pingdotgg/t3code/pull/642", |
| 14 | baseRefName: "main", |
| 15 | headRefName: "fix/git-action-default-without-origin", |
| 16 | isCrossRepository: true, |
| 17 | headRepository: { id: "R_1", name: "t3code" }, |
| 18 | headRepositoryOwner: { login: "binbandit" }, |
| 19 | }, |
| 20 | ]), |
| 21 | ); |
| 22 | |
| 23 | expect(Result.getOrThrow(decoded)[0]).toMatchObject({ |
| 24 | headRepositoryNameWithOwner: "binbandit/t3code", |
| 25 | headRepositoryOwnerLogin: "binbandit", |
| 26 | }); |
| 27 | }); |
| 28 | |
| 29 | it("reads lowercase closed and merged states", () => { |
| 30 | const row = (number: number, state: string) => ({ |
| 31 | number, |
| 32 | title: "PR", |
| 33 | url: `https://github.com/pingdotgg/codething-mvp/pull/${number}`, |
| 34 | baseRefName: "main", |
| 35 | headRefName: "feature/status-lowercase-state", |
| 36 | state, |
| 37 | }); |
| 38 | const decoded = decodeGitHubPullRequestListJson( |
| 39 | JSON.stringify([row(16, "closed"), row(17, "merged"), row(18, "open")]), |
| 40 | ); |
| 41 | |
| 42 | expect(Result.getOrThrow(decoded).map((pr) => pr.state)).toEqual(["closed", "merged", "open"]); |
| 43 | }); |