2024-10-17 00:29:39 +07:00
|
|
|
import * as urlHelper from '../src/url-helper'
|
|
|
|
|
|
|
|
describe('isGhes tests', () => {
|
|
|
|
it('basics', async () => {
|
|
|
|
expect(urlHelper.isGhes()).toBeFalsy()
|
|
|
|
expect(urlHelper.isGhes('https://github.com')).toBeFalsy()
|
2024-10-17 18:49:31 +07:00
|
|
|
expect(urlHelper.isGhes('https://contoso.ghe.com')).toBeFalsy()
|
2024-10-17 00:29:39 +07:00
|
|
|
expect(urlHelper.isGhes('https://test.github.localhost')).toBeFalsy()
|
2024-10-17 18:56:31 +07:00
|
|
|
expect(urlHelper.isGhes('https://src.onpremise.fabrikam.com')).toBeTruthy()
|
2024-10-17 00:29:39 +07:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('getServerApiUrl tests', () => {
|
|
|
|
it('basics', async () => {
|
|
|
|
expect(urlHelper.getServerApiUrl()).toBe('https://api.github.com')
|
2024-10-17 01:15:26 +07:00
|
|
|
expect(urlHelper.getServerApiUrl('https://github.com')).toBe(
|
|
|
|
'https://api.github.com'
|
|
|
|
)
|
|
|
|
expect(urlHelper.getServerApiUrl('https://GitHub.com')).toBe(
|
|
|
|
'https://api.github.com'
|
|
|
|
)
|
2024-10-17 18:49:31 +07:00
|
|
|
expect(urlHelper.getServerApiUrl('https://contoso.ghe.com')).toBe(
|
|
|
|
'https://api.contoso.ghe.com'
|
2024-10-17 01:15:26 +07:00
|
|
|
)
|
2024-10-17 18:49:31 +07:00
|
|
|
expect(urlHelper.getServerApiUrl('https://fabrikam.GHE.COM')).toBe(
|
|
|
|
'https://api.fabrikam.ghe.com'
|
2024-10-17 01:15:26 +07:00
|
|
|
)
|
|
|
|
expect(
|
2024-10-17 18:56:31 +07:00
|
|
|
urlHelper.getServerApiUrl('https://src.onpremise.fabrikam.com')
|
|
|
|
).toBe('https://src.onpremise.fabrikam.com/api/v3')
|
2024-10-17 00:29:39 +07:00
|
|
|
})
|
|
|
|
})
|