krona-staff/tests/unit/config.test.ts

21 lines
786 B
TypeScript

import { describe, expect, it } from 'vitest';
import { loadConfig } from '../../src/config.js';
const base = {
DATABASE_URL: 'postgres://localhost/staff',
STANDALONE_TENANT_ID: '01J00000000000000000000000',
STANDALONE_ACTOR_ID: '01J00000000000000000000001',
};
describe('runtime modes', () => {
it('allows the compatible standalone adapter', () =>
expect(loadConfig(base).STAFF_RUNTIME_MODE).toBe('standalone'));
it('fails closed when platform contracts are missing', () =>
expect(() => loadConfig({ ...base, STAFF_RUNTIME_MODE: 'platform' })).toThrow(
/PLATFORM_GATEWAY_URL/,
));
it('rejects standalone mode in production', () =>
expect(() => loadConfig({ ...base, NODE_ENV: 'production' })).toThrow(
/standalone is not allowed/,
));
});