config.test.ts•1.67 kB
import { describe, it, expect } from 'vitest';
import { config } from '@/config.js';
describe('Configuration', () => {
it('should have valid default configuration values', () => {
expect(typeof config.userAgent).toBe('string');
expect(typeof config.timeout).toBe('number');
expect(typeof config.maxRetries).toBe('number');
expect(typeof config.rateLimitDelay).toBe('number');
expect(typeof config.verbose).toBe('boolean');
expect(typeof config.cacheEnabled).toBe('boolean');
expect(typeof config.maxResults).toBe('number');
expect(config.timeout).toBeGreaterThan(0);
expect(config.maxRetries).toBeGreaterThanOrEqual(0);
expect(config.rateLimitDelay).toBeGreaterThanOrEqual(0);
expect(config.maxResults).toBeGreaterThan(0);
expect(config.maxResults).toBeLessThanOrEqual(20);
});
it('should have a working log function', () => {
expect(typeof config.log).toBe('function');
// Should not throw when called
expect(() => config.log('test message')).not.toThrow();
});
it('should contain appropriate user agent string', () => {
expect(config.userAgent).toMatch(/LLMResearcher/);
expect(config.userAgent).toMatch(/Mozilla/);
});
it('should have reasonable timeout values', () => {
expect(config.timeout).toBeGreaterThanOrEqual(10000); // At least 10 seconds
expect(config.timeout).toBeLessThanOrEqual(120000); // At most 2 minutes
});
it('should have appropriate rate limiting', () => {
expect(config.rateLimitDelay).toBeGreaterThanOrEqual(500); // At least 0.5 seconds
expect(config.rateLimitDelay).toBeLessThanOrEqual(5000); // At most 5 seconds
});
});