import { describe, expect, it } from 'bun:test';
import * as handlerRegistryExports from '../src';
import { HandlerRegistry } from '../src';

describe('Handler Registry Package Exports', () => {
  it('should export HandlerRegistry class', () => {
    expect(handlerRegistryExports.HandlerRegistry).toBeDefined();
    expect(handlerRegistryExports.HandlerRegistry).toBe(HandlerRegistry);
  });

  it('should export correct types', () => {
    // Type tests - compile-time checks
    type TestHandlerMetadata = handlerRegistryExports.HandlerMetadata;
    type TestOperationMetadata = handlerRegistryExports.OperationMetadata;
    type TestScheduleMetadata = handlerRegistryExports.ScheduleMetadata;
    type TestHandlerConfiguration = handlerRegistryExports.HandlerConfiguration;
    type TestRegistryStats = handlerRegistryExports.RegistryStats;
    type TestHandlerDiscoveryResult = handlerRegistryExports.HandlerDiscoveryResult;

    // Runtime type usage tests
    const testHandler: TestHandlerMetadata = {
      name: 'TestHandler',
      serviceName: 'test-service',
      operations: [],
    };

    const testOperation: TestOperationMetadata = {
      operationName: 'testOperation',
      handlerName: 'TestHandler',
      operationPath: 'test.operation',
      serviceName: 'test-service',
    };

    const testSchedule: TestScheduleMetadata = {
      handlerName: 'TestHandler',
      scheduleName: 'test-schedule',
      expression: '*/5 * * * *',
      serviceName: 'test-service',
    };

    const testConfig: TestHandlerConfiguration = {
      handlerName: 'TestHandler',
      batchSize: 10,
      timeout: 5000,
      retries: 3,
    };

    const testStats: TestRegistryStats = {
      totalHandlers: 5,
      totalOperations: 10,
      totalSchedules: 3,
      handlersByService: {
        service1: 2,
        service2: 3,
      },
    };

    const testDiscoveryResult: TestHandlerDiscoveryResult = {
      handlers: [testHandler],
      operations: [testOperation],
      schedules: [testSchedule],
      configurations: [testConfig],
    };

    expect(testHandler).toBeDefined();
    expect(testOperation).toBeDefined();
    expect(testSchedule).toBeDefined();
    expect(testConfig).toBeDefined();
    expect(testStats).toBeDefined();
    expect(testDiscoveryResult).toBeDefined();
  });

  it('should create HandlerRegistry instance', () => {
    const registry = new HandlerRegistry();
    expect(registry).toBeInstanceOf(HandlerRegistry);
  });
});
