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

import { getDefaultModelAbility, handleTagClick } from '../model-ability';

describe('model ability labels', () => {
  it('只保留当前可用的视觉、推理和工具能力', () => {
    const abilities = getDefaultModelAbility();

    expect(abilities.map((item) => item.field)).toEqual([
      'supportThinking',
      'supportTool',
      'supportImage',
    ]);
  });

  it('支持手动切换自动识别的能力', () => {
    const abilities = getDefaultModelAbility();
    const toolAbility = abilities.find((item) => item.field === 'supportTool');
    const formData = {
      supportImage: false,
      supportThinking: false,
      supportTool: false,
    };

    expect(toolAbility).toBeDefined();
    if (!toolAbility) {
      throw new Error('缺少工具能力标签');
    }

    handleTagClick(toolAbility, formData);

    expect(toolAbility.selected).toBe(true);
    expect(formData.supportTool).toBe(true);
  });
});
