Files
TREK/server/tests/unit/nest/llm-parse/llm-client.factory.test.ts
T
Maurice 407bacf66e test(llm-parse): cover the extraction router, client factory and import jobs
The new LLM extraction router shipped with little branch coverage, dropping src/nest below the 80% gate. Add unit tests for routeExtraction (flights/single/union/error paths, deterministic booking-wide fill), the native Ollama format client, the provider factory, the local-router service path with its type-aware text cap, the flat->schema.org mapper's remaining reservation types, and the background import-jobs runner. Also remove the now-unused validate.ts (only its FlatLike type was still referenced; moved to flat-schemas).
2026-06-26 22:12:10 +02:00

24 lines
1.2 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { createLlmClient } from '../../../../src/nest/llm-parse/llm-client.factory';
import { OpenAiCompatibleClient } from '../../../../src/nest/llm-parse/clients/openai-compatible.client';
import { AnthropicClient } from '../../../../src/nest/llm-parse/clients/anthropic.client';
import type { ResolvedLlmConfig } from '../../../../src/services/llmConfig';
const cfg = (provider: string): ResolvedLlmConfig =>
({ provider, model: 'm', baseUrl: 'http://x', multimodal: false } as unknown as ResolvedLlmConfig);
describe('createLlmClient', () => {
it('returns the Anthropic client for the anthropic provider', () => {
expect(createLlmClient(cfg('anthropic'))).toBeInstanceOf(AnthropicClient);
});
it('returns the OpenAI-compatible client for openai and local', () => {
expect(createLlmClient(cfg('openai'))).toBeInstanceOf(OpenAiCompatibleClient);
expect(createLlmClient(cfg('local'))).toBeInstanceOf(OpenAiCompatibleClient);
});
it('falls back to the OpenAI-compatible client for an unknown provider', () => {
expect(createLlmClient(cfg('something-else'))).toBeInstanceOf(OpenAiCompatibleClient);
});
});