mikser-io-git 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ import { describe, it } from 'node:test'
2
+ import assert from 'node:assert/strict'
3
+
4
+ import { parseRepoUrl } from '../lib/repo-url.js'
5
+
6
+ describe('parseRepoUrl', () => {
7
+ it('parses a github.com URL and defaults apiOrigin to api.github.com', () => {
8
+ const r = parseRepoUrl('https://github.com/almero-digital-marketing/gpoint-content.git')
9
+ assert.deepEqual(r, { owner: 'almero-digital-marketing', repo: 'gpoint-content', apiOrigin: 'https://api.github.com' })
10
+ })
11
+
12
+ it('parses without the .git suffix identically', () => {
13
+ const r = parseRepoUrl('https://github.com/org/repo')
14
+ assert.equal(r.owner, 'org')
15
+ assert.equal(r.repo, 'repo')
16
+ })
17
+
18
+ it('a self-hosted Gitea URL uses its own origin as apiOrigin (adapter appends /api/v1)', () => {
19
+ const r = parseRepoUrl('https://git.almero.bg/org/content.git')
20
+ assert.deepEqual(r, { owner: 'org', repo: 'content', apiOrigin: 'https://git.almero.bg' })
21
+ })
22
+
23
+ it('tolerates a trailing slash', () => {
24
+ const r = parseRepoUrl('https://git.almero.bg/org/content/')
25
+ assert.equal(r.repo, 'content')
26
+ })
27
+
28
+ it('throws on a URL with no owner/repo path', () => {
29
+ assert.throws(() => parseRepoUrl('https://github.com/'), /cannot derive owner\/repo/)
30
+ })
31
+
32
+ it('throws on garbage input', () => {
33
+ assert.throws(() => parseRepoUrl('not a url'), /not a valid URL/)
34
+ })
35
+ })