Skip to main content
Glama
nlp-service.test.ts2.14 kB
import { NlpService } from '../nlp-service'; import { FormConfig, QuestionType, SubmissionBehavior, FormTheme } from '../../models'; describe('NlpService', () => { let nlpService: NlpService; let baseFormConfig: FormConfig; beforeEach(() => { nlpService = new NlpService(); baseFormConfig = { title: 'Original Title', questions: [ { id: '1', type: QuestionType.TEXT, label: 'Existing Question', required: false, }, ], settings: { submissionBehavior: SubmissionBehavior.MESSAGE, submissionMessage: 'Thanks!', }, branding: { theme: FormTheme.DEFAULT, }, }; }); describe('customizeFormConfig', () => { it('should add a new question to the form', () => { const prompt = 'add question: What is your quest?'; const modifiedConfig = nlpService.customizeFormConfig(prompt, baseFormConfig); expect(modifiedConfig.questions).toHaveLength(2); expect(modifiedConfig.questions[1]?.label).toBe('What is your quest?'); }); it('should remove an existing question from the form', () => { const prompt = 'remove question: Existing Question'; const modifiedConfig = nlpService.customizeFormConfig(prompt, baseFormConfig); expect(modifiedConfig.questions).toHaveLength(0); }); it('should update the form title', () => { const prompt = 'update title: A New Title'; const modifiedConfig = nlpService.customizeFormConfig(prompt, baseFormConfig); expect(modifiedConfig.title).toBe('A New Title'); }); it('should handle multiple commands', () => { const prompt = ` update title: A Better Form add question: Your favorite color? (choice) remove question: Existing Question `; const modifiedConfig = nlpService.customizeFormConfig(prompt, baseFormConfig); expect(modifiedConfig.title).toBe('A Better Form'); expect(modifiedConfig.questions).toHaveLength(1); expect(modifiedConfig.questions[0]?.label).toBe('Your favorite color?'); }); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/learnwithcc/tally-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server