mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
85 lines
2.1 KiB
TypeScript
85 lines
2.1 KiB
TypeScript
import { describe, it, expect, vi } from 'vitest';
|
|
import { render, screen } from '@testing-library/react';
|
|
import { TestApp } from '@/test/TestApp';
|
|
import { ModelInput } from './ModelInput';
|
|
|
|
// Mock the hooks
|
|
vi.mock('@/hooks/useAISettings', () => ({
|
|
useAISettings: () => ({
|
|
settings: {
|
|
providers: [
|
|
{ id: 'test-provider', name: 'Test Provider', baseURL: 'https://api.test.com' }
|
|
]
|
|
}
|
|
})
|
|
}));
|
|
|
|
vi.mock('@/hooks/useProviderModels', () => ({
|
|
useProviderModels: () => ({
|
|
models: [
|
|
{
|
|
id: 'text-model',
|
|
name: 'Text Model',
|
|
provider: 'test-provider',
|
|
fullId: 'test-provider/text-model',
|
|
inputModalities: ['text'],
|
|
outputModalities: ['text']
|
|
},
|
|
{
|
|
id: 'image-model',
|
|
name: 'Image Model',
|
|
provider: 'test-provider',
|
|
fullId: 'test-provider/image-model',
|
|
inputModalities: ['text'],
|
|
outputModalities: ['image']
|
|
},
|
|
{
|
|
id: 'multimodal-model',
|
|
name: 'Multimodal Model',
|
|
provider: 'test-provider',
|
|
fullId: 'test-provider/multimodal-model',
|
|
inputModalities: ['text', 'image'],
|
|
outputModalities: ['text', 'image']
|
|
},
|
|
{
|
|
id: 'no-modalities-model',
|
|
name: 'No Modalities Model',
|
|
provider: 'test-provider',
|
|
fullId: 'test-provider/no-modalities-model'
|
|
}
|
|
],
|
|
isLoading: false,
|
|
error: null,
|
|
refetch: vi.fn()
|
|
})
|
|
}));
|
|
|
|
describe('ModelInput', () => {
|
|
it('renders without crashing', () => {
|
|
const onChange = vi.fn();
|
|
render(
|
|
<TestApp>
|
|
<ModelInput value="" onChange={onChange} />
|
|
</TestApp>
|
|
);
|
|
|
|
expect(screen.getByRole('combobox')).toBeInTheDocument();
|
|
});
|
|
|
|
it('accepts modelFilter prop', () => {
|
|
const onChange = vi.fn();
|
|
const modelFilter = (model: { modalities?: string[] }) => model.modalities?.includes('image');
|
|
render(
|
|
<TestApp>
|
|
<ModelInput
|
|
value=""
|
|
onChange={onChange}
|
|
modelFilter={modelFilter}
|
|
/>
|
|
</TestApp>
|
|
);
|
|
|
|
expect(screen.getByRole('combobox')).toBeInTheDocument();
|
|
});
|
|
});
|