Open History to see the last commit
1import { describe, expect, it } from "vitest";
2
3import { parsePullRequestReference } from "./pullRequestReference";
4
5describe("parsePullRequestReference", () => {
6 it("accepts GitHub pull request URLs", () => {
7 expect(parsePullRequestReference("https://github.com/pingdotgg/t3code/pull/42")).toBe(
8 "https://github.com/pingdotgg/t3code/pull/42",
9 );
10 });
11
12 it("accepts raw numbers", () => {
13 expect(parsePullRequestReference("42")).toBe("42");
14 });
15
16 it("accepts #number references", () => {
17 expect(parsePullRequestReference("#42")).toBe("42");
18 });
19
20 it("accepts gh pr checkout commands with raw numbers", () => {
21 expect(parsePullRequestReference("gh pr checkout 42")).toBe("42");
22 });
23
24 it("accepts gh pr checkout commands with #number references", () => {
25 expect(parsePullRequestReference("gh pr checkout #42")).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});