/**
 * /v1/models conversion tests — small but it locks the OpenAI shape.
 */
import { describe, it, expect } from 'vitest';
import { buildModelsResponse } from './models-endpoint.js';

describe('buildModelsResponse', () => {
  it('returns the OpenAI list envelope even when empty', () => {
    const resp = buildModelsResponse([]);
    expect(resp.object).toBe('list');
    expect(resp.data).toEqual([]);
  });

  it('maps each backend id to a model entry', () => {
    const resp = buildModelsResponse([
      { id: 'gpu-a', endpoint: 'http://a/v1', model: 'qwen3:8b', maxSlots: 4 },
      { id: 'gpu-b', endpoint: 'http://b/v1', model: 'qwen3:14b', maxSlots: 4 },
    ]);
    expect(resp.data).toEqual([
      { id: 'gpu-a', object: 'model', owned_by: 'aao-gateway' },
      { id: 'gpu-b', object: 'model', owned_by: 'aao-gateway' },
    ]);
  });
});
