import { ConfigService } from '@nestjs/config';
import { ConfigurableHttpServer, configureHttpServer } from './http-server.config';

describe('configureHttpServer', () => {
  it('applies transport settings from application configuration', () => {
    const values: Record<string, number> = {
      'reliability.serverRequestTimeoutMs': 90_000,
      'reliability.headersTimeoutMs': 12_000,
      'reliability.keepAliveTimeoutMs': 4_000,
      'reliability.maxRequestsPerSocket': 500,
    };
    const config = {
      get: jest.fn((key: string) => values[key]),
    } as unknown as ConfigService;
    const server: ConfigurableHttpServer = {
      requestTimeout: 0,
      headersTimeout: 0,
      keepAliveTimeout: 0,
      maxRequestsPerSocket: 0,
    };

    configureHttpServer(server, config);

    expect(server).toEqual({
      requestTimeout: 90_000,
      headersTimeout: 12_000,
      keepAliveTimeout: 4_000,
      maxRequestsPerSocket: 500,
    });
  });
});
