0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-01-27 22:59:51 -05:00
verdaccio/packages/core/url/tests/combineBaseUrl.spec.ts
Juan Picado 0c7b19b192
chore: migrate vitest packages (#4777)
* chore: migrate core to vitest

* chore: migrate url module

* chore: migrate tarball package

* chore: migrate loader package

* chore: migrate hook package

* chore: migrate signature package

* chore: migrate utils package
2024-08-03 19:39:22 +02:00

29 lines
1.1 KiB
TypeScript

import { describe, expect, test } from 'vitest';
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/'
);
});
});