config.test.ts
1,052 bytes
| 1 | import { describe, expect, it } from 'vitest'; |
|---|---|
| 2 | import { parseDebateConfig } from './config'; |
| 3 | |
| 4 | const validInput = { |
| 5 | question: 'Should we ship this change?', |
| 6 | models: ['openai/gpt-4o', 'anthropic/claude-3.5-sonnet', 'google/gemini-pro-1.5'], |
| 7 | chairmanModel: 'x-ai/grok-2-1212', |
| 8 | }; |
| 9 | |
| 10 | describe('parseDebateConfig', () => { |
| 11 | it('trims the question before returning the resolved config', () => { |
| 12 | const config = parseDebateConfig({ |
| 13 | ...validInput, |
| 14 | question: ' Should we ship this change? ', |
| 15 | }); |
| 16 | |
| 17 | expect(config.question).toBe('Should we ship this change?'); |
| 18 | }); |
| 19 | |
| 20 | it('rejects questions that contain only whitespace', () => { |
| 21 | expect(() => |
| 22 | parseDebateConfig({ |
| 23 | ...validInput, |
| 24 | question: ' ', |
| 25 | }), |
| 26 | ).toThrow(); |
| 27 | }); |
| 28 | |
| 29 | it('fills the optional debate settings with defaults', () => { |
| 30 | const config = parseDebateConfig(validInput); |
| 31 | |
| 32 | expect(config).toMatchObject({ |
| 33 | maxRounds: 3, |
| 34 | convergenceThreshold: 85, |
| 35 | temperature: 0.7, |
| 36 | perModelTimeoutMs: 90_000, |
| 37 | }); |
| 38 | }); |
| 39 | }); |
| 40 | |