From 83e5ca1dbb4148745fe41fe763462732d35c40e7 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Tue, 3 Feb 2026 08:11:31 +0000 Subject: [PATCH] fix: Add missing tests directory and files --- tests/unit/config.test.ts | 63 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests/unit/config.test.ts diff --git a/tests/unit/config.test.ts b/tests/unit/config.test.ts new file mode 100644 index 0000000..043793e --- /dev/null +++ b/tests/unit/config.test.ts @@ -0,0 +1,63 @@ +import { validateGlobalConfig, validateWorkspaceConfig } from '../../src/config'; + +describe('validateGlobalConfig', () => { + it('should accept valid config', () => { + const config = { + workspacePath: './workspaces', + defaultBranch: 'main', + autoInstall: true, + templates: { default: '/templates/default' } + }; + expect(() => validateGlobalConfig(config)).not.toThrow(); + }); + + it('should use defaults for missing values', () => { + const config = {}; + const validated = validateGlobalConfig(config); + expect(validated.workspacePath).toBe('./.agent-workspaces'); + expect(validated.defaultBranch).toBe('main'); + expect(validated.autoInstall).toBe(true); + }); + + it('should reject invalid workspace path', () => { + const config = { workspacePath: 123 }; + expect(() => validateGlobalConfig(config)).toThrow(); + }); + + it('should reject invalid autoInstall type', () => { + const config = { autoInstall: 'yes' }; + expect(() => validateGlobalConfig(config)).toThrow(); + }); +}); + +describe('validateWorkspaceConfig', () => { + it('should accept valid workspace config', () => { + const config = { + agentName: 'test-agent', + branch: 'agent-test-agent', + createdAt: '2024-01-15T10:30:00Z', + mainBranch: 'main', + environment: { AGENT_ID: 'test-agent' } + }; + expect(() => validateWorkspaceConfig(config)).not.toThrow(); + }); + + it('should reject missing agent name', () => { + const config = { + branch: 'agent-test', + createdAt: new Date().toISOString(), + mainBranch: 'main' + }; + expect(() => validateWorkspaceConfig(config)).toThrow(); + }); + + it('should reject invalid date format', () => { + const config = { + agentName: 'test', + branch: 'agent-test', + createdAt: 'not-a-date', + mainBranch: 'main' + }; + expect(() => validateWorkspaceConfig(config)).toThrow(); + }); +});