-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathpullRequestReference.test.ts
More file actions
35 lines (29 loc) · 1.08 KB
/
pullRequestReference.test.ts
File metadata and controls
35 lines (29 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { describe, expect, it } from "vitest";
import { parsePullRequestReference, parsePullRequestReferenceParts } from "./pullRequestReference";
describe("parsePullRequestReference", () => {
it("accepts GitHub pull request URLs", () => {
expect(parsePullRequestReference("https://github.com/pingdotgg/okcode/pull/42")).toBe(
"https://github.com/pingdotgg/okcode/pull/42",
);
});
it("extracts repository metadata from GitHub pull request URLs", () => {
expect(
parsePullRequestReferenceParts("https://github.com/pingdotgg/okcode/pull/42/files"),
).toEqual({
kind: "url",
reference: "https://github.com/pingdotgg/okcode/pull/42/files",
number: "42",
owner: "pingdotgg",
repo: "okcode",
});
});
it("accepts raw numbers", () => {
expect(parsePullRequestReference("42")).toBe("42");
});
it("accepts #number references", () => {
expect(parsePullRequestReference("#42")).toBe("#42");
});
it("rejects non-pull-request input", () => {
expect(parsePullRequestReference("feature/my-branch")).toBeNull();
});
});