Files
t3code/packages/contracts/src/git.test.ts
T
Jason LasterandJulius Marminge 223c3dc800 chore(ci): add and apply fmt:check script (#779)
* Add  formatting conventions

* Add a fmt lint check

* rely on defaults

---------

Co-authored-by: Julius Marminge <[email protected]>
2026-03-10 00:17:18 -07:00

59 lines
1.7 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { Schema } from "effect";
import {
GitCreateWorktreeInput,
GitPreparePullRequestThreadInput,
GitResolvePullRequestResult,
} from "./git";
const decodeCreateWorktreeInput = Schema.decodeUnknownSync(GitCreateWorktreeInput);
const decodePreparePullRequestThreadInput = Schema.decodeUnknownSync(
GitPreparePullRequestThreadInput,
);
const decodeResolvePullRequestResult = Schema.decodeUnknownSync(GitResolvePullRequestResult);
describe("GitCreateWorktreeInput", () => {
it("accepts omitted newBranch for existing-branch worktrees", () => {
const parsed = decodeCreateWorktreeInput({
cwd: "/repo",
branch: "feature/existing",
path: "/tmp/worktree",
});
expect(parsed.newBranch).toBeUndefined();
expect(parsed.branch).toBe("feature/existing");
});
});
describe("GitPreparePullRequestThreadInput", () => {
it("accepts pull request references and mode", () => {
const parsed = decodePreparePullRequestThreadInput({
cwd: "/repo",
reference: "#42",
mode: "worktree",
});
expect(parsed.reference).toBe("#42");
expect(parsed.mode).toBe("worktree");
});
});
describe("GitResolvePullRequestResult", () => {
it("decodes resolved pull request metadata", () => {
const parsed = decodeResolvePullRequestResult({
pullRequest: {
number: 42,
title: "PR threads",
url: "https://github.com/pingdotgg/codething-mvp/pull/42",
baseBranch: "main",
headBranch: "feature/pr-threads",
state: "open",
},
});
expect(parsed.pullRequest.number).toBe(42);
expect(parsed.pullRequest.headBranch).toBe("feature/pr-threads");
});
});