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
Christopher Kolstad 3a65847aa7
Migrate to jest (#854)
* Migrate to jest
* Use --force-exit until dns close handle issue https://github.com/facebook/jest/issues/9982

Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
2021-05-28 11:10:24 +02:00

32 lines
1.1 KiB
TypeScript

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