98 lines
3.7 KiB
TypeScript
98 lines
3.7 KiB
TypeScript
import {
|
|
getEnrichmentPrompt,
|
|
getSamplePromptForDocType
|
|
} from '../src';
|
|
|
|
describe('Prompts', () => {
|
|
describe('getEnrichmentPrompt()', () => {
|
|
it('should return a string prompt', () => {
|
|
const prompt = getEnrichmentPrompt('Test content');
|
|
expect(typeof prompt).toBe('string');
|
|
expect(prompt.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it('should include the content in the prompt', () => {
|
|
const content = 'This is my test document content';
|
|
const prompt = getEnrichmentPrompt(content);
|
|
expect(prompt).toContain(content);
|
|
});
|
|
|
|
it('should include document type in prompt', () => {
|
|
const prompt = getEnrichmentPrompt('Content', 'pdf');
|
|
expect(prompt).toContain('Document type: pdf');
|
|
});
|
|
|
|
it('should default to markdown doc type', () => {
|
|
const prompt = getEnrichmentPrompt('Content');
|
|
expect(prompt).toContain('Document type: markdown');
|
|
});
|
|
|
|
it('should include JSON structure requirements', () => {
|
|
const prompt = getEnrichmentPrompt('Content');
|
|
expect(prompt).toContain('"summary"');
|
|
expect(prompt).toContain('"tags"');
|
|
expect(prompt).toContain('"category"');
|
|
expect(prompt).toContain('"audience"');
|
|
expect(prompt).toContain('"doc_purpose"');
|
|
expect(prompt).toContain('"complexity"');
|
|
expect(prompt).toContain('"actionable"');
|
|
expect(prompt).toContain('"key_technologies"');
|
|
});
|
|
|
|
it('should include valid audience values', () => {
|
|
const prompt = getEnrichmentPrompt('Content');
|
|
expect(prompt).toContain('all | beginner | intermediate | expert');
|
|
});
|
|
|
|
it('should include valid doc_purpose values', () => {
|
|
const prompt = getEnrichmentPrompt('Content');
|
|
expect(prompt).toContain('reference | tutorial | troubleshooting | conceptual | guide | specification');
|
|
});
|
|
|
|
it('should include complexity scale', () => {
|
|
const prompt = getEnrichmentPrompt('Content');
|
|
expect(prompt).toContain('1-5');
|
|
expect(prompt).toContain('1=overview');
|
|
expect(prompt).toContain('5=deep implementation');
|
|
});
|
|
|
|
it('should include guidelines for tags', () => {
|
|
const prompt = getEnrichmentPrompt('Content');
|
|
expect(prompt).toContain('tags');
|
|
expect(prompt).toContain('SPECIFIC terms');
|
|
});
|
|
|
|
it('should request JSON-only response', () => {
|
|
const prompt = getEnrichmentPrompt('Content');
|
|
expect(prompt).toContain('valid JSON only');
|
|
expect(prompt).toContain('No explanation');
|
|
});
|
|
|
|
it('should wrap content with delimiters', () => {
|
|
const content = 'Test content';
|
|
const prompt = getEnrichmentPrompt(content);
|
|
expect(prompt).toContain('---\n' + content + '\n---');
|
|
});
|
|
});
|
|
|
|
describe('getSamplePromptForDocType()', () => {
|
|
it('should return correct descriptions for known types', () => {
|
|
expect(getSamplePromptForDocType('pdf')).toBe('PDF document');
|
|
expect(getSamplePromptForDocType('word')).toBe('Word document');
|
|
expect(getSamplePromptForDocType('email')).toBe('Email message');
|
|
expect(getSamplePromptForDocType('image')).toBe('Image with OCR text');
|
|
expect(getSamplePromptForDocType('audio')).toBe('Audio transcript');
|
|
expect(getSamplePromptForDocType('video')).toBe('Video transcript');
|
|
expect(getSamplePromptForDocType('presentation')).toBe('Presentation slides');
|
|
expect(getSamplePromptForDocType('excel')).toBe('Spreadsheet data');
|
|
expect(getSamplePromptForDocType('markdown')).toBe('Markdown document');
|
|
});
|
|
|
|
it('should return "document" for unknown types', () => {
|
|
expect(getSamplePromptForDocType('unknown')).toBe('document');
|
|
expect(getSamplePromptForDocType('xyz')).toBe('document');
|
|
expect(getSamplePromptForDocType('')).toBe('document');
|
|
});
|
|
});
|
|
});
|