Something went wrong. Try again.
Fork of backnotprop/plannotator with reduced surface area
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465import { 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 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, }); });});