import { buildFileUrl } from './buildFileUrl'; describe('buildFileUrl', () => { describe('default base URL', () => { it('builds correct URL with default base', () => { expect(buildFileUrl('site_settings', 'ss1', 'cv_2024.pdf')).toBe( 'http://127.0.0.1:8090/api/files/site_settings/ss1/cv_2024.pdf', ); }); }); describe('custom base URL', () => { it('uses provided baseUrl when given', () => { expect(buildFileUrl('photos', 'rec1', 'avatar.png', 'https://pb.example.com')).toBe( 'https://pb.example.com/api/files/photos/rec1/avatar.png', ); }); }); describe('different collections, records, filenames', () => { it('handles projects collection', () => { expect(buildFileUrl('projects', 'proj42', 'screenshot.jpg', 'http://127.0.0.1:8090')).toBe( 'http://127.0.0.1:8090/api/files/projects/proj42/screenshot.jpg', ); }); it('handles contacts collection', () => { expect(buildFileUrl('contacts', 'cid99', 'photo.webp', 'http://127.0.0.1:8090')).toBe( 'http://127.0.0.1:8090/api/files/contacts/cid99/photo.webp', ); }); }); });