This commit is contained in:
Tiara Rodney 2026-03-15 03:02:41 +01:00
commit 932d4ad420
No known key found for this signature in database
GPG key ID: 5CD8EC1D46106723
46 changed files with 5800 additions and 0 deletions

View file

@ -0,0 +1,44 @@
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/<branch>", () => {
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/<branch>", () => {
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/<branch>", () => {
expect(buildOriginUrl("https://gitlab.com/org/repo", "develop", "TODO", 5))
.toBe("https://gitlab.com/org/repo/-/blob/develop/TODO#5")
})
})