2026-07-16 09:59:27 +08:00
|
|
|
import { getDruidIndexUrl, getProductionApiBaseUrl, normalizePublicUrl } from '@/utils/publicUrl';
|
2026-07-15 08:46:40 +08:00
|
|
|
|
|
|
|
|
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/',
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
2026-07-16 09:59:27 +08:00
|
|
|
it('builds the Druid index URL from the public API base URL', () => {
|
|
|
|
|
expect(getDruidIndexUrl('http://47.111.103.66')).toBe(
|
|
|
|
|
'http://47.111.103.66/api/shihezi/druid/index.html',
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
2026-07-15 08:46:40 +08:00
|
|
|
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);
|
|
|
|
|
});
|
|
|
|
|
});
|