import { describe, expect, it } from 'bun:test'; import * as handlersExports from '../src'; import { BaseHandler, ScheduledHandler } from '../src'; describe('Handlers Package Exports', () => { it('should export base handler classes', () => { expect(handlersExports.BaseHandler).toBeDefined(); expect(handlersExports.ScheduledHandler).toBeDefined(); expect(handlersExports.BaseHandler).toBe(BaseHandler); expect(handlersExports.ScheduledHandler).toBe(ScheduledHandler); }); it('should export utility functions', () => { expect(handlersExports.createJobHandler).toBeDefined(); expect(typeof handlersExports.createJobHandler).toBe('function'); }); it('should export decorators', () => { expect(handlersExports.Handler).toBeDefined(); expect(handlersExports.Operation).toBeDefined(); expect(handlersExports.QueueSchedule).toBeDefined(); expect(handlersExports.ScheduledOperation).toBeDefined(); expect(handlersExports.Disabled).toBeDefined(); // All decorators should be functions expect(typeof handlersExports.Handler).toBe('function'); expect(typeof handlersExports.Operation).toBe('function'); expect(typeof handlersExports.QueueSchedule).toBe('function'); expect(typeof handlersExports.ScheduledOperation).toBe('function'); expect(typeof handlersExports.Disabled).toBe('function'); }); it('should export auto-registration utilities', () => { expect(handlersExports.autoRegisterHandlers).toBeDefined(); expect(handlersExports.createAutoHandlerRegistry).toBeDefined(); expect(typeof handlersExports.autoRegisterHandlers).toBe('function'); expect(typeof handlersExports.createAutoHandlerRegistry).toBe('function'); }); it('should export types', () => { // Type tests - compile-time checks type TestJobScheduleOptions = handlersExports.JobScheduleOptions; type TestExecutionContext = handlersExports.ExecutionContext; type TestIHandler = handlersExports.IHandler; type TestJobHandler = handlersExports.JobHandler; type TestScheduledJob = handlersExports.ScheduledJob; type TestHandlerConfig = handlersExports.HandlerConfig; type TestHandlerConfigWithSchedule = handlersExports.HandlerConfigWithSchedule; type TestTypedJobHandler = handlersExports.TypedJobHandler; type TestHandlerMetadata = handlersExports.HandlerMetadata; type TestOperationMetadata = handlersExports.OperationMetadata; type TestIServiceContainer = handlersExports.IServiceContainer; // Runtime type usage tests const scheduleOptions: TestJobScheduleOptions = { pattern: '*/5 * * * *', priority: 10, }; const executionContext: TestExecutionContext = { jobId: 'test-job', attemptNumber: 1, maxAttempts: 3, }; const handlerMetadata: TestHandlerMetadata = { handlerName: 'TestHandler', operationName: 'testOperation', queueName: 'test-queue', options: {}, }; const operationMetadata: TestOperationMetadata = { operationName: 'testOp', handlerName: 'TestHandler', operationPath: 'test.op', serviceName: 'test-service', }; expect(scheduleOptions).toBeDefined(); expect(executionContext).toBeDefined(); expect(handlerMetadata).toBeDefined(); expect(operationMetadata).toBeDefined(); }); it('should have correct class inheritance', () => { // ScheduledHandler should extend BaseHandler const mockServices = { cache: null, globalCache: null, queueManager: null, proxy: null, browser: null, mongodb: null, postgres: null, questdb: null, } as any; const handler = new ScheduledHandler(mockServices); expect(handler).toBeInstanceOf(BaseHandler); expect(handler).toBeInstanceOf(ScheduledHandler); }); });