import { describe, expect, it } from 'vitest';

import {
  modelIdsForProfile,
  modelOptionsFromIds,
  suggestedModelOptions,
  supportsCustomModelOptions,
} from '../../src/lib/provider-model-options';

describe('provider model options', () => {
  it('returns stored profile model ids without duplicates', () => {
    expect(
      modelIdsForProfile({
        defaultModel: 'gpt-5.1-codex',
        modelOptions: ['gpt-5.1-codex', 'gpt-5'],
      }),
    ).toEqual(['gpt-5.1-codex', 'gpt-5']);
  });

  it('provides local suggestions for built-in providers', () => {
    expect(
      suggestedModelOptions('openai').some(
        (model) => model.id === 'gpt-5.1-codex',
      ),
    ).toBe(true);
  });

  it('supports custom model ids only for gateway-style providers', () => {
    expect(supportsCustomModelOptions('openrouter')).toBe(true);
    expect(supportsCustomModelOptions('openai')).toBe(false);
  });

  it('normalizes model ids into select options', () => {
    expect(modelOptionsFromIds(['openai/gpt-5.1-codex'])[0]).toMatchObject({
      id: 'openai/gpt-5.1-codex',
      label: 'Gpt 5.1 Codex',
    });
  });
});
