import { describe, it, expect } from "vitest" import { normalizeRemoteUrl, buildOriginUrl, } from "../../../lib/bugzilla/origin" describe("normalizeRemoteUrl", () => { it("passes HTTPS URLs through", () => { expect(normalizeRemoteUrl("https://github.com/user/repo")) .toBe("https://github.com/user/repo") }) it("strips trailing .git", () => { expect(normalizeRemoteUrl("https://github.com/user/repo.git")) .toBe("https://github.com/user/repo") }) it("converts SSH URLs to HTTPS", () => { expect(normalizeRemoteUrl("git@github.com:user/repo.git")) .toBe("https://github.com/user/repo") }) it("converts Bitbucket SSH URLs", () => { expect(normalizeRemoteUrl("git@bitbucket.org:org/project.git")) .toBe("https://bitbucket.org/org/project") }) }) describe("buildOriginUrl", () => { it("builds Bitbucket URL with src/", () => { expect(buildOriginUrl("git@bitbucket.org:byteb4rb1e/mime-todo-spec.git", "master", "TODO", 1)) .toBe("https://bitbucket.org/byteb4rb1e/mime-todo-spec/src/master/TODO#1") }) it("builds GitHub URL with blob/", () => { expect(buildOriginUrl("https://github.com/user/repo", "main", "TODO", 42)) .toBe("https://github.com/user/repo/blob/main/TODO#42") }) it("builds GitLab URL with -/blob/", () => { expect(buildOriginUrl("https://gitlab.com/org/repo", "develop", "TODO", 5)) .toBe("https://gitlab.com/org/repo/-/blob/develop/TODO#5") }) })