Open History to see the last commit
1import { describe, expect, it } from "vitest";
2import { Schema } from "effect";
3
4import {
5 GitCreateWorktreeInput,
6 GitPreparePullRequestThreadInput,
7 GitResolvePullRequestResult,
8} from "./git";
9
10const decodeCreateWorktreeInput = Schema.decodeUnknownSync(GitCreateWorktreeInput);
11const decodePreparePullRequestThreadInput = Schema.decodeUnknownSync(
12 GitPreparePullRequestThreadInput,
13);
14const decodeResolvePullRequestResult = Schema.decodeUnknownSync(GitResolvePullRequestResult);
15
16describe("GitCreateWorktreeInput", () => {
17 it("accepts omitted newBranch for existing-branch worktrees", () => {
18 const parsed = decodeCreateWorktreeInput({
19 cwd: "/repo",
20 branch: "feature/existing",
21 path: "/tmp/worktree",
22 });
23
24 expect(parsed.newBranch).toBeUndefined();
25 expect(parsed.branch).toBe("feature/existing");
26 });
27});
28
29describe("GitPreparePullRequestThreadInput", () => {
30 it("accepts pull request references and mode", () => {
31 const parsed = decodePreparePullRequestThreadInput({
32 cwd: "/repo",
33 reference: "#42",
34 mode: "worktree",
35 });
36
37 expect(parsed.reference).toBe("#42");
38 expect(parsed.mode).toBe("worktree");
39 });
40});
41
42describe("GitResolvePullRequestResult", () => {
43 it("decodes resolved pull request metadata", () => {
44 const parsed = decodeResolvePullRequestResult({
45 pullRequest: {
46 number: 42,
47 title: "PR threads",
48 url: "https://github.com/pingdotgg/codething-mvp/pull/42",
49 baseBranch: "main",
50 headBranch: "feature/pr-threads",
51 state: "open",
52 },
53 });
54
55 expect(parsed.pullRequest.number).toBe(42);
56 expect(parsed.pullRequest.headBranch).toBe("feature/pr-threads");
57 });
58});