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
Fredrik Strand Oseberg 85a544bbd6
Feat/format base path (#828)
* chore: update changelog

* feat: add formatBaseUri helper

* feat: call formatBaseUri on server options

* feat: call formatBaseUri on user options

* fix: update test

* fix: disable consistent return
2021-05-03 12:28:59 +02:00

33 lines
1.1 KiB
TypeScript

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');
});