import { ServiceContainer, registerSocketServices, registerRestServices } from "../core/bootstrap"; import { Option } from "../types/config/options"; import { IOptionManager, IAuthManager, ISocketChannelManager, } from "../types/services/managers"; import { IWebSocketClient, IHttpClient, ILogger, ILoggerFactory, } from "../types/services/clients"; import { IConnection } from "../types/services/connection"; /** * Test-specific service container with enhanced mocking capabilities */ export class TestContainer extends ServiceContainer { /** * Register a mock implementation for a service * * @param key - Service identifier * @param mockInstance - Mock instance to use */ mock(key: string, mockInstance: T): void { // Clear any existing instance this.clearService(key); // Register the mock as a singleton this.register( key, () => mockInstance, { lifetime: "singleton" } ); } /** * Override a service registration with a new factory * * @param key - Service identifier * @param factory - New factory function */ override(key: string, factory: (container: ServiceContainer) => T): void { // Clear any existing instance this.clearService(key); // Register the override this.register(key, factory, { lifetime: "singleton" }); } /** * Clear a specific service instance and registration * * @param key - Service identifier */ private clearService(key: string): void { // Access private members for testing purposes (this as any).instances.delete(key); (this as any).definitions.delete(key); } } /** * Create a test container with Socket services pre-registered * * @param instanceId - Test instance identifier * @param options - Socket options * @returns Configured test container */ export function createTestSocketContainer( instanceId: string = "test-socket", options: Partial