Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { parsePullRequestReference } from "./pullRequestReference";
4
5describe("parsePullRequestReference", () => {
6 it.each([
7 "https://github.com/pingdotgg/t3code/pull/42",
8 "https://dev.azure.com/acme/project/_git/t3code/pullrequest/42",
9 "https://gitlab.com/group/project/-/merge_requests/42",
10 "https://acme.visualstudio.com/project/_git/t3code/pullrequest/42",
11 ])("accepts pull request URL %s", (url) => {
12 expect(parsePullRequestReference(url)).toBe(url);
13 });
14
15 it.each([
16 "42",
17 "#42",
18 "gh pr checkout 42",
19 "gh pr checkout #42",
20 "glab mr checkout 42",
21 "az repos pr checkout --id 42",
22 "az repos pr checkout --id=42",
23 "az repos pr checkout --id 42 --remote-name origin",
24 ])("extracts the pull request number from %s", (input) => {
25 expect(parsePullRequestReference(input)).toBe("42");
26 });
27
28 it("accepts gh pr checkout commands with GitHub pull request URLs", () => {
29 expect(
30 parsePullRequestReference("gh pr checkout https://github.com/pingdotgg/t3code/pull/42"),
31 ).toBe("https://github.com/pingdotgg/t3code/pull/42");
32 });
33
34 it("rejects non-pull-request input", () => {
35 expect(parsePullRequestReference("feature/my-branch")).toBeNull();
36 });
37});