2022-09-08 08:00:42 +00:00
|
|
|
import { getApiBaseUrl, getSourceUrlBase } from './url';
|
2021-08-05 15:05:22 +00:00
|
|
|
|
2022-09-08 08:00:42 +00:00
|
|
|
describe('util/github/url', () => {
|
2021-08-05 15:05:22 +00:00
|
|
|
describe('getSourceUrlBase', () => {
|
|
|
|
it('ensures trailing slash', () => {
|
|
|
|
const sourceUrl = getSourceUrlBase('https://gh.my-company.com');
|
|
|
|
expect(sourceUrl).toBe('https://gh.my-company.com/');
|
|
|
|
});
|
2022-04-12 14:49:49 +00:00
|
|
|
|
2021-08-05 15:05:22 +00:00
|
|
|
it('defaults to github.com', () => {
|
2022-06-20 14:24:37 +00:00
|
|
|
const sourceUrl = getSourceUrlBase(undefined);
|
2021-08-05 15:05:22 +00:00
|
|
|
expect(sourceUrl).toBe('https://github.com/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('getApiBaseUrl', () => {
|
|
|
|
it('maps to api.github.com', () => {
|
|
|
|
const apiUrl = getApiBaseUrl('https://github.com/');
|
|
|
|
expect(apiUrl).toBe('https://api.github.com/');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('supports local github installations', () => {
|
2022-06-16 06:42:23 +00:00
|
|
|
expect(getApiBaseUrl('https://gh.my-company.com/')).toBe(
|
|
|
|
'https://gh.my-company.com/api/v3/'
|
|
|
|
);
|
|
|
|
expect(getApiBaseUrl('https://gh.my-company.com/api/v3/')).toBe(
|
|
|
|
'https://gh.my-company.com/api/v3/'
|
|
|
|
);
|
2021-08-05 15:05:22 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|