import { describe, expect, it } from 'bun:test'; import * as handlersExports from '../src'; import { BaseHandler } from '../src'; describe('Handlers Package Exports', () => { it('should export base handler classes', () => { expect(handlersExports.BaseHandler).toBeDefined(); expect(handlersExports.BaseHandler).toBe(BaseHandler); }); 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 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(); }); });