MeshiTrack/packages/api/src/modules/llm/no-op-llm.provider.test.ts

60 lines
2.4 KiB
TypeScript
Raw Normal View History

2026-05-14 14:47:23 +09:00
import { describe, it, expect, vi } from 'vitest';
import { NoOpLlmProvider } from './no-op-llm.provider.js';
import { LLM_PROVIDER } from './llm-provider.interface.js';
describe(NoOpLlmProvider.name, () => {
const provider = new NoOpLlmProvider();
it('exports LLM_PROVIDER symbol', () => {
expect(typeof LLM_PROVIDER).toBe('symbol');
});
it('extractNutrition returns null and warns', async () => {
const spy = vi.spyOn(console, 'warn').mockImplementation(() => {});
const result = await provider.extractNutrition({ text: 'apple' });
expect(result).toBeNull();
expect(spy).toHaveBeenCalledWith(expect.stringContaining('extractNutrition'));
spy.mockRestore();
});
it('parseRecipe returns null and warns', async () => {
const spy = vi.spyOn(console, 'warn').mockImplementation(() => {});
const result = await provider.parseRecipe('pasta recipe');
expect(result).toBeNull();
expect(spy).toHaveBeenCalledWith(expect.stringContaining('parseRecipe'));
spy.mockRestore();
});
it('parseRecipeFromUrl returns null and warns', async () => {
const spy = vi.spyOn(console, 'warn').mockImplementation(() => {});
const result = await provider.parseRecipeFromUrl('https://example.com');
expect(result).toBeNull();
expect(spy).toHaveBeenCalledWith(expect.stringContaining('parseRecipeFromUrl'));
spy.mockRestore();
});
it('parseReceipt returns null and warns', async () => {
const spy = vi.spyOn(console, 'warn').mockImplementation(() => {});
const result = await provider.parseReceipt(Buffer.from('fake-image'));
expect(result).toBeNull();
expect(spy).toHaveBeenCalledWith(expect.stringContaining('parseReceipt'));
spy.mockRestore();
});
it('suggestMealPlan returns null and warns', async () => {
const spy = vi.spyOn(console, 'warn').mockImplementation(() => {});
const result = await provider.suggestMealPlan({ householdId: 'hh1' });
expect(result).toBeNull();
expect(spy).toHaveBeenCalledWith(expect.stringContaining('suggestMealPlan'));
spy.mockRestore();
});
it('parseNaturalLanguage returns null and warns', async () => {
const spy = vi.spyOn(console, 'warn').mockImplementation(() => {});
const result = await provider.parseNaturalLanguage('add milk');
expect(result).toBeNull();
expect(spy).toHaveBeenCalledWith(expect.stringContaining('parseNaturalLanguage'));
spy.mockRestore();
});
});