0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/packages/core/url/tests/combineBaseUrl.spec.ts

28 lines
1.1 KiB
TypeScript
Raw Normal View History

import { combineBaseUrl } from '../src';
describe('combineBaseUrl', () => {
test('should create a URI', () => {
expect(combineBaseUrl('http', 'domain')).toEqual('http://domain/');
});
test('should create a base url for registry', () => {
expect(combineBaseUrl('http', 'domain.com', '')).toEqual('http://domain.com/');
expect(combineBaseUrl('http', 'domain.com', '/')).toEqual('http://domain.com/');
expect(combineBaseUrl('http', 'domain.com', '/prefix/')).toEqual('http://domain.com/prefix/');
expect(combineBaseUrl('http', 'domain.com', '/prefix/deep')).toEqual(
'http://domain.com/prefix/deep/'
);
expect(combineBaseUrl('http', 'domain.com', 'prefix/')).toEqual('http://domain.com/prefix/');
expect(combineBaseUrl('http', 'domain.com', 'prefix')).toEqual('http://domain.com/prefix/');
});
test('invalid url prefix', () => {
expect(combineBaseUrl('http', 'domain.com', 'only-prefix')).toEqual(
'http://domain.com/only-prefix/'
);
expect(combineBaseUrl('https', 'domain.com', 'only-prefix')).toEqual(
'https://domain.com/only-prefix/'
);
});
});