import { describe, expect, it } from 'vitest';
import { hyperloopUserBase } from '@/lib/vigthoria-services';

describe('HyperLoop user endpoint resolution', () => {
  it('uses the direct production host for identity-bound user JWTs', () => {
    expect(hyperloopUserBase('https://hyperloop.vigthoria.io')).toBe('https://hyperloop.vigthoria.io');
    expect(hyperloopUserBase('https://hyperloop.vigthoria.io/')).toBe('https://hyperloop.vigthoria.io');
  });

  it('preserves explicit self-hosted endpoints', () => {
    expect(hyperloopUserBase('http://127.0.0.1:8020')).toBe('http://127.0.0.1:8020');
    expect(hyperloopUserBase('https://hyperloop.internal.example')).toBe('https://hyperloop.internal.example');
  });

  it('uses the authenticated production proxy by default', () => {
    expect(hyperloopUserBase('')).toBe('https://hyperloop.vigthoria.io');
  });
});
