Files
openmaic/OpenMAIC/tests/prompts/loader.test.ts
2026-08-16 14:58:47 +08:00

36 lines
1.2 KiB
TypeScript

import { describe, test, expect } from 'vitest';
import { loadPrompt, loadSnippet, buildPrompt } from '@openmaic/generation';
describe('@openmaic/generation prompt loader', () => {
test('loads a known template + interpolates variables', () => {
const result = buildPrompt('slide-actions', {
title: 'Test Slide',
keyPoints: '1. point one',
description: 'desc',
elements: '[]',
courseContext: '',
agents: '',
userProfile: '',
languageDirective: 'en',
});
expect(result).not.toBeNull();
expect(result!.system.length).toBeGreaterThan(100);
expect(result!.user).toContain('Test Slide');
});
test('loads a snippet', () => {
const s = loadSnippet('json-output-rules');
expect(s).toContain('JSON');
});
test('returns null for unknown promptId', () => {
// @ts-expect-error — testing runtime behavior with invalid id
expect(loadPrompt('does-not-exist')).toBeNull();
});
test('throws on unknown snippetId instead of passing through literal', () => {
// @ts-expect-error — testing runtime behavior with invalid id
expect(() => loadSnippet('does-not-exist')).toThrow(/Snippet not found/);
});
});