2021-05-03 12:28:59 +02:00
|
|
|
import { formatBaseUri } from './format-base-uri';
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
test('formatBaseUri returns the correct path when the path is the right format', () => {
|
2021-05-03 12:28:59 +02:00
|
|
|
const result = formatBaseUri('/hosted');
|
2021-05-28 11:10:24 +02:00
|
|
|
expect(result === '/hosted').toBe(true);
|
2021-05-03 12:28:59 +02:00
|
|
|
});
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
test('formatBaseUri returns the correct path when the path lacking initial slash', () => {
|
2021-05-03 12:28:59 +02:00
|
|
|
const result = formatBaseUri('hosted');
|
2021-05-28 11:10:24 +02:00
|
|
|
expect(result === '/hosted').toBe(true);
|
2021-05-03 12:28:59 +02:00
|
|
|
});
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
test('formatBaseUri returns the correct path when the path has both initial and trailing slash', () => {
|
2021-05-03 12:28:59 +02:00
|
|
|
const result = formatBaseUri('/hosted/');
|
2021-05-28 11:10:24 +02:00
|
|
|
expect(result === '/hosted').toBe(true);
|
2021-05-03 12:28:59 +02:00
|
|
|
});
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
test('formatBaseUri returns the correct path when the path has only trailing slash', () => {
|
2021-05-03 12:28:59 +02:00
|
|
|
const result = formatBaseUri('hosted/');
|
2021-05-28 11:10:24 +02:00
|
|
|
expect(result === '/hosted').toBe(true);
|
2021-05-03 12:28:59 +02:00
|
|
|
});
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
test('formatBaseUri returns empty string when called without input', () => {
|
2021-05-03 12:28:59 +02:00
|
|
|
const result = formatBaseUri(undefined);
|
2021-05-28 11:10:24 +02:00
|
|
|
expect(result === '').toBe(true);
|
2021-05-03 12:28:59 +02:00
|
|
|
});
|
|
|
|
|
2021-05-28 11:10:24 +02:00
|
|
|
test('formatBaseUri handles levels of paths', () => {
|
2021-05-03 12:28:59 +02:00
|
|
|
const result = formatBaseUri('hosted/multi/path');
|
2021-05-28 11:10:24 +02:00
|
|
|
expect(result === '/hosted/multi/path').toBe(true);
|
2021-05-03 12:28:59 +02:00
|
|
|
});
|