Read-only mirror — the public repositories of the Forgejo instance, refreshed every 10 minutes. The live instance (fg.dieschoenewolke.de) is reachable only over the VPN; clone here with https://git.dieschoenewolke.de/git/<owner>/<repo>.git.
summaryrefslogtreecommitdiff
path: root/__test__/url-helper.test.ts
diff options
context:
space:
mode:
authorJohn Wesley Walker III <81404201+jww3@users.noreply.github.com>2024-10-23 15:59:08 +0200
committerGitHub <noreply@github.com>2024-10-23 15:59:08 +0200
commitf89cd7f9f040b2299ac3b2130f78cfbf56cbebdf (patch)
tree79c1a058a08412c34d8427bb281bf7f3bba6fa6f /__test__/url-helper.test.ts
parent06229e648730e5ff920410853f1f4ec7dacf988f (diff)
Expand unit test coverage (#1946)
Diffstat (limited to '__test__/url-helper.test.ts')
-rw-r--r--__test__/url-helper.test.ts37
1 files changed, 37 insertions, 0 deletions
diff --git a/__test__/url-helper.test.ts b/__test__/url-helper.test.ts
index 27f6606..57cb28f 100644
--- a/__test__/url-helper.test.ts
+++ b/__test__/url-helper.test.ts
@@ -24,13 +24,50 @@ describe('getServerUrl tests', () => {
})
describe('isGhes tests', () => {
+ const pristineEnv = process.env
+
+ beforeEach(() => {
+ jest.resetModules()
+ process.env = {...pristineEnv}
+ })
+
+ afterAll(() => {
+ process.env = pristineEnv
+ })
+
it('basics', async () => {
+ delete process.env['GITHUB_SERVER_URL']
expect(urlHelper.isGhes()).toBeFalsy()
expect(urlHelper.isGhes('https://github.com')).toBeFalsy()
expect(urlHelper.isGhes('https://contoso.ghe.com')).toBeFalsy()
expect(urlHelper.isGhes('https://test.github.localhost')).toBeFalsy()
expect(urlHelper.isGhes('https://src.onpremise.fabrikam.com')).toBeTruthy()
})
+
+ it('returns false when the GITHUB_SERVER_URL environment variable is not defined', async () => {
+ delete process.env['GITHUB_SERVER_URL']
+ expect(urlHelper.isGhes()).toBeFalsy()
+ })
+
+ it('returns false when the GITHUB_SERVER_URL environment variable is set to github.com', async () => {
+ process.env['GITHUB_SERVER_URL'] = 'https://github.com'
+ expect(urlHelper.isGhes()).toBeFalsy()
+ })
+
+ it('returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL', async () => {
+ process.env['GITHUB_SERVER_URL'] = 'https://contoso.ghe.com'
+ expect(urlHelper.isGhes()).toBeFalsy()
+ })
+
+ it('returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix', async () => {
+ process.env['GITHUB_SERVER_URL'] = 'https://mock-github.localhost'
+ expect(urlHelper.isGhes()).toBeFalsy()
+ })
+
+ it('returns true when the GITHUB_SERVER_URL environment variable is set to some other URL', async () => {
+ process.env['GITHUB_SERVER_URL'] = 'https://src.onpremise.fabrikam.com'
+ expect(urlHelper.isGhes()).toBeTruthy()
+ })
})
describe('getServerApiUrl tests', () => {