import { describe, it, expect } from "vitest"; import { parseRepoPath } from "./commands"; describe("parseRepoPath", () => { it("解析标准 HTTPS GitHub URL", () => { expect(parseRepoPath("https://github.com/facebook/react")).toBe("facebook/react"); }); it("解析带 .git 后缀的 URL", () => { expect(parseRepoPath("https://github.com/facebook/react.git")).toBe("facebook/react"); }); it("解析 SSH 格式 URL", () => { expect(parseRepoPath("git@github.com:facebook/react.git")).toBe("facebook/react"); }); it("非 GitHub URL 返回 null", () => { expect(parseRepoPath("https://gitlab.com/foo/bar")).toBeNull(); }); it("空字符串返回 null", () => { expect(parseRepoPath("")).toBeNull(); }); it("纯域名无路径返回 null", () => { expect(parseRepoPath("https://github.com")).toBeNull(); }); it("非 URL 的随机字符串返回 null", () => { expect(parseRepoPath("not-a-url")).toBeNull(); }); });