1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-10-18 20:09:08 +02:00
unleash.unleash/src/lib/util/format-base-uri.test.ts

33 lines
1.1 KiB
TypeScript
Raw Normal View History

import { formatBaseUri } from './format-base-uri';
import test from 'ava';
test('formatBaseUri returns the correct path when the path is the right format', t => {
const result = formatBaseUri('/hosted');
t.true(result === '/hosted');
});
test('formatBaseUri returns the correct path when the path lacking initial slash', t => {
const result = formatBaseUri('hosted');
t.true(result === '/hosted');
});
test('formatBaseUri returns the correct path when the path has both initial and trailing slash', t => {
const result = formatBaseUri('/hosted/');
t.true(result === '/hosted');
});
test('formatBaseUri returns the correct path when the path has only trailing slash', t => {
const result = formatBaseUri('hosted/');
t.true(result === '/hosted');
});
test('formatBaseUri returns empty string when called without input', t => {
const result = formatBaseUri(undefined);
t.true(result === '');
});
test('formatBaseUri handles levels of paths', t => {
const result = formatBaseUri('hosted/multi/path');
t.true(result === '/hosted/multi/path');
});