/** * Unit tests for backend configuration module. * Tests environment variable validation using Zod schema. */ import { describe, it, expect } from 'bun:test'; describe('Config Module', () => { it('should export config object with expected keys', async () => { // We set JWT_SECRET env var to ensure validation passes process.env.JWT_SECRET = 'test-secret-for-unit-tests-at-least-16-chars'; // Dynamic import to get fresh module const { config } = await import('../../src/config'); expect(config).toBeDefined(); expect(typeof config.PORT).toBe('number'); expect(typeof config.JWT_SECRET).toBe('string'); expect(config.JWT_SECRET.length).toBeGreaterThanOrEqual(16); expect(typeof config.DATABASE_PATH).toBe('string'); expect(typeof config.PLANE_BASE_URL).toBe('string'); expect(typeof config.GITEA_BASE_URL).toBe('string'); }); it('should have correct default PORT', async () => { process.env.JWT_SECRET = 'test-secret-for-unit-tests-at-least-16-chars'; const { config } = await import('../../src/config'); // Default PORT from schema is 3200 expect(config.PORT).toBe(3200); }); it('should have valid default URLs', async () => { process.env.JWT_SECRET = 'test-secret-for-unit-tests-at-least-16-chars'; const { config } = await import('../../src/config'); expect(config.PLANE_BASE_URL).toMatch(/^https?:\/\//); expect(config.GITEA_BASE_URL).toMatch(/^https?:\/\//); }); });