import { describe, expect, it } from 'vitest';
import { environmentValidationSchema } from '../src/config/env.validation';

describe('environment validation', () => {
  it('accepts a complete development configuration', () => {
    const { error, value } = environmentValidationSchema.validate({
      APP_ORIGIN: 'http://localhost:3000',
      DATABASE_URL: 'postgresql://user:password@localhost:5432/ck_terminal_test',
    });

    expect(error).toBeUndefined();
    expect(value.PORT).toBe(4000);
    expect(value.AUTH_ALLOW_REGISTRATION).toBe(false);
  });

  it('rejects a missing database URL', () => {
    const { error } = environmentValidationSchema.validate({
      APP_ORIGIN: 'http://localhost:3000',
    });

    expect(error).toBeDefined();
  });
});
