mirror of
https://github.com/mediacms-io/mediacms.git
synced 2026-01-21 15:52:58 -05:00
feat: frontend unit tests
This commit is contained in:
23
frontend/tests/utils/helpers/formatInnerLink.test.ts
Normal file
23
frontend/tests/utils/helpers/formatInnerLink.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { formatInnerLink } from '../../../src/static/js/utils/helpers/formatInnerLink';
|
||||
|
||||
describe('js/utils/helpers', () => {
|
||||
describe('formatInnerLink', () => {
|
||||
test('Returns the same absolute URL unchanged', () => {
|
||||
const url = 'https://example.com/path?x=1#hash';
|
||||
const base = 'https://base.example.org';
|
||||
expect(formatInnerLink(url, base)).toBe(url);
|
||||
});
|
||||
|
||||
test('Constructs absolute URL from relative path with leading slash', () => {
|
||||
const url = '/images/picture.png';
|
||||
const base = 'https://media.example.com';
|
||||
expect(formatInnerLink(url, base)).toBe('https://media.example.com/images/picture.png');
|
||||
});
|
||||
|
||||
test('Constructs absolute URL from relative path without leading slash', () => {
|
||||
const url = 'assets/file.txt';
|
||||
const base = 'https://cdn.example.com';
|
||||
expect(formatInnerLink(url, base)).toBe('https://cdn.example.com/assets/file.txt');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user