init
This commit is contained in:
commit
932d4ad420
46 changed files with 5800 additions and 0 deletions
44
tests/lib/bugzilla/origin.test.ts
Normal file
44
tests/lib/bugzilla/origin.test.ts
Normal 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")
|
||||
})
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue