mirror of
https://github.com/backnotprop/plannotator.git
synced 2026-09-14 14:17:26 +08:00
56df64c751
Adds current-architecture GitButler workspace, stack, and branch review support across Bun and Pi while preserving the existing Git, JJ, and P4 paths. Co-authored-by: Dan Susman <56033661+dansusman@users.noreply.github.com>
73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
import { describe, expect, test } from "bun:test";
|
|
import { parseReviewArgs } from "./review-args";
|
|
|
|
describe("parseReviewArgs", () => {
|
|
test("defaults to auto VCS and local PR checkout", () => {
|
|
expect(parseReviewArgs("")).toEqual({
|
|
prUrl: undefined,
|
|
vcsType: undefined,
|
|
useLocal: true,
|
|
});
|
|
});
|
|
|
|
test("parses --git without a PR URL", () => {
|
|
expect(parseReviewArgs("--git")).toEqual({
|
|
prUrl: undefined,
|
|
vcsType: "git",
|
|
useLocal: true,
|
|
});
|
|
});
|
|
|
|
test("parses --gitbutler without a PR URL", () => {
|
|
expect(parseReviewArgs("--gitbutler")).toEqual({
|
|
prUrl: undefined,
|
|
vcsType: "gitbutler",
|
|
useLocal: true,
|
|
});
|
|
});
|
|
|
|
test("parses PR URLs before or after --git", () => {
|
|
expect(parseReviewArgs("--git https://github.com/acme/repo/pull/12")).toEqual({
|
|
prUrl: "https://github.com/acme/repo/pull/12",
|
|
vcsType: "git",
|
|
useLocal: true,
|
|
});
|
|
expect(parseReviewArgs("https://github.com/acme/repo/pull/12 --git")).toEqual({
|
|
prUrl: "https://github.com/acme/repo/pull/12",
|
|
vcsType: "git",
|
|
useLocal: true,
|
|
});
|
|
});
|
|
|
|
test("preserves --no-local for PR review mode", () => {
|
|
expect(parseReviewArgs("--no-local https://github.com/acme/repo/pull/12")).toEqual({
|
|
prUrl: "https://github.com/acme/repo/pull/12",
|
|
vcsType: undefined,
|
|
useLocal: false,
|
|
});
|
|
});
|
|
|
|
test("accepts argv arrays from the compiled CLI", () => {
|
|
expect(parseReviewArgs(["--git", "--no-local", "https://github.com/acme/repo/pull/12"])).toEqual({
|
|
prUrl: "https://github.com/acme/repo/pull/12",
|
|
vcsType: "git",
|
|
useLocal: false,
|
|
});
|
|
});
|
|
|
|
test("strips wrapping quotes from string and argv inputs", () => {
|
|
expect(parseReviewArgs(`--git "https://github.com/acme/repo/pull/12"`).prUrl)
|
|
.toBe("https://github.com/acme/repo/pull/12");
|
|
expect(parseReviewArgs(["--git", "\"https://github.com/acme/repo/pull/12\""]).prUrl)
|
|
.toBe("https://github.com/acme/repo/pull/12");
|
|
});
|
|
|
|
test("keeps non-url positional input as local review mode", () => {
|
|
expect(parseReviewArgs("--git not-a-url")).toEqual({
|
|
prUrl: undefined,
|
|
vcsType: "git",
|
|
useLocal: true,
|
|
});
|
|
});
|
|
});
|