import { getProductionApiBaseUrl, normalizePublicUrl } from '@/utils/publicUrl'; describe('public URL helpers', () => { it('builds the production API base URL from the browser origin', () => { expect(getProductionApiBaseUrl('http://39.98.44.136:6024')).toBe( 'http://39.98.44.136:6024/api/shihezi/', ); }); it('replaces an internal backend origin with the browser origin', () => { expect( normalizePublicUrl( 'http://127.0.0.1:9091/h5/outdoor-fair/company.html?fairId=8&companyId=93007', 'http://39.98.44.136:6024', ), ).toBe('http://39.98.44.136:6024/h5/outdoor-fair/company.html?fairId=8&companyId=93007'); }); it('keeps an already public URL unchanged', () => { const url = 'https://jobs.example.com/h5/outdoor-fair/company.html?fairId=8&companyId=93007'; expect(normalizePublicUrl(url, 'http://39.98.44.136:6024')).toBe(url); }); });