import { C as BoundInjectionToken, M as InjectionToken, n as Registry } from "../registry-DKbKWFvJ.cjs"; import { t as Container } from "../container-r1KP4F-n.cjs"; //#region src/testing/types.d.mts /** * Tracks method calls on a mocked service. */ interface MethodCallRecord { method: string; args: unknown[]; timestamp: number; result?: unknown; error?: Error; } /** * Tracks lifecycle events for a service. */ interface LifecycleRecord { event: 'created' | 'initialized' | 'destroyed'; timestamp: number; instanceName: string; } /** * Statistics about a mocked service. */ interface MockServiceStats { instanceCount: number; methodCalls: MethodCallRecord[]; lifecycleEvents: LifecycleRecord[]; } /** * A node in the dependency graph. */ interface DependencyNode { token: string; instanceName: string; scope: string; dependencies: string[]; dependents: string[]; } /** * Serializable dependency graph for snapshot testing. */ interface DependencyGraph { nodes: Record; rootTokens: string[]; } /** * Binding configuration for TestContainer. */ interface BindingBuilder { /** * Bind to a concrete value. */ toValue(value: T): void; /** * Bind to a class implementation. */ toClass T>(cls: C): void; /** * Bind to a factory function. */ toFactory(factory: () => T | Promise): void; } /** * Provider configuration for UnitTestContainer. */ interface ProviderConfig { token: InjectionToken | BoundInjectionToken | (new (...args: any[]) => T); useValue?: T; useClass?: new (...args: any[]) => T; useFactory?: () => T | Promise; } /** * Options for TestContainer. */ interface TestContainerOptions { /** * Parent registry. Defaults to globalRegistry. * Pass `null` to create a completely isolated container. */ parentRegistry?: Registry | null; /** * Logger for debugging. */ logger?: Console | null; } /** * Options for UnitTestContainer. */ interface UnitTestContainerOptions { /** * List of providers to register. Only these services can be resolved. */ providers: ProviderConfig[]; /** * If true, unregistered dependencies will be auto-mocked instead of throwing. * Default: false (throws on unregistered dependencies) */ allowUnregistered?: boolean; /** * Logger for debugging. */ logger?: Console | null; } //#endregion //#region src/testing/test-container.d.mts type AnyToken$1 = InjectionToken | BoundInjectionToken | (new (...args: any[]) => any); /** * TestContainer extends Container with testing utilities. * * Provides simple value/class binding for integration/e2e tests, * plus assertion helpers and dependency graph inspection. * * @example * ```ts * const container = new TestContainer() * * // Bind mock values * container.bind(DatabaseToken).toValue(mockDatabase) * container.bind(UserService).toClass(MockUserService) * * // Use container normally * const service = await container.get(MyService) * * // Assert on container state * container.expectResolved(MyService) * container.expectSingleton(MyService) * ``` */ declare class TestContainer extends Container { private readonly testRegistry; private readonly methodCalls; private readonly lifecycleEvents; private readonly instanceCounts; private readonly boundTokens; /** * Creates a new TestContainer. * * @param options - Configuration options * @param options.parentRegistry - Parent registry. Defaults to globalRegistry. * Pass `null` for a completely isolated container. * @param options.logger - Optional logger for debugging. * * @example * ```ts * // Uses globalRegistry as parent (default) * const container = new TestContainer() * * // Isolated container (no access to @Injectable classes) * const isolated = new TestContainer({ parentRegistry: null }) * * // Custom parent registry * const custom = new TestContainer({ parentRegistry: myRegistry }) * ``` */ constructor(options?: TestContainerOptions); /** * Creates a binding builder for the given token. * * @example * ```ts * container.bind(UserService).toValue(mockUserService) * container.bind(DatabaseToken).toClass(MockDatabase) * container.bind(ConfigToken).toFactory(() => ({ apiKey: 'test' })) * container.bind(BOUND_CONFIG_TOKEN).toValue(overrideValue) * ``` */ bind(token: InjectionToken | BoundInjectionToken | (new (...args: any[]) => T)): BindingBuilder; /** * Clears all bindings and resets container state. */ clear(): Promise; /** * Asserts that a service has been resolved at least once. */ expectResolved(token: AnyToken$1): void; /** * Asserts that a service has NOT been resolved. */ expectNotResolved(token: AnyToken$1): void; /** * Asserts that a service is registered as singleton scope. */ expectSingleton(token: AnyToken$1): void; /** * Asserts that a service is registered as transient scope. */ expectTransient(token: AnyToken$1): void; /** * Asserts that a service is registered as request scope. */ expectRequestScoped(token: AnyToken$1): void; /** * Asserts that two service resolutions return the same instance. */ expectSameInstance(token: AnyToken$1): Promise; /** * Asserts that two service resolutions return different instances. */ expectDifferentInstances(token: AnyToken$1): Promise; /** * Asserts that a service's onServiceInit was called. */ expectInitialized(token: AnyToken$1): void; /** * Asserts that a service's onServiceDestroy was called. */ expectDestroyed(token: AnyToken$1): void; /** * Asserts that a service has NOT been destroyed. */ expectNotDestroyed(token: AnyToken$1): void; /** * Records a method call for tracking. * Call this from your mock implementations. */ recordMethodCall(token: AnyToken$1, method: string, args: unknown[], result?: unknown, error?: Error): void; /** * Records a lifecycle event for tracking. */ recordLifecycleEvent(token: AnyToken$1, event: 'created' | 'initialized' | 'destroyed', instanceName: string): void; /** * Asserts that a method was called on a service. */ expectCalled(token: AnyToken$1, method: string): void; /** * Asserts that a method was called with specific arguments. */ expectCalledWith(token: AnyToken$1, method: string, expectedArgs: unknown[]): void; /** * Asserts that a method was called a specific number of times. */ expectCallCount(token: AnyToken$1, method: string, count: number): void; /** * Gets all recorded method calls for a service. */ getMethodCalls(token: AnyToken$1): MethodCallRecord[]; /** * Gets statistics about a mocked service. */ getServiceStats(token: AnyToken$1): MockServiceStats; /** * Clears all recorded method calls. */ clearMethodCalls(): void; /** * Gets the dependency graph for snapshot testing. * Returns a serializable structure that can be used with vitest snapshots. */ getDependencyGraph(): DependencyGraph; /** * Gets a simplified dependency graph showing only token relationships. * Useful for cleaner snapshot comparisons. */ getSimplifiedDependencyGraph(): Record; private resolveToken; private registerValueBinding; private registerClassBinding; private registerFactoryBinding; private argsMatch; } //#endregion //#region src/testing/unit-test-container.d.mts type AnyToken = InjectionToken | BoundInjectionToken | (new (...args: any[]) => any); /** * UnitTestContainer for isolated unit testing. * * Only services explicitly listed in `providers` can be resolved. * All method calls are automatically tracked via proxies. * Unregistered dependencies throw by default, or can be auto-mocked. * * @example * ```ts * const container = new UnitTestContainer({ * providers: [ * { token: UserService, useClass: MockUserService }, * { token: ConfigToken, useValue: { apiUrl: 'test' } }, * ], * }) * * const service = await container.get(UserService) * * // All method calls are automatically tracked * await service.findUser('123') * * container.expectCalled(UserService, 'findUser') * container.expectCalledWith(UserService, 'findUser', ['123']) * ``` */ declare class UnitTestContainer extends Container { private readonly testRegistry; private readonly methodCalls; private readonly lifecycleEvents; private readonly instanceCounts; private readonly registeredTokenIds; private readonly autoMockedTokenIds; private allowUnregistered; constructor(options: UnitTestContainerOptions); /** * Enables auto-mocking for unregistered dependencies. * Call this to switch from strict mode to auto-mock mode. */ enableAutoMocking(): this; /** * Disables auto-mocking (strict mode). * Unregistered dependencies will throw. */ disableAutoMocking(): this; /** * Override get to wrap instances in tracking proxies. */ get(token: any, args?: unknown): Promise; /** * Clears all state and disposes the container. */ clear(): Promise; /** * Asserts that a service has been resolved at least once. */ expectResolved(token: AnyToken): void; /** * Asserts that a service has NOT been resolved. */ expectNotResolved(token: AnyToken): void; /** * Asserts that a service was auto-mocked (not in providers list). */ expectAutoMocked(token: AnyToken): void; /** * Asserts that a service was NOT auto-mocked (is in providers list). */ expectNotAutoMocked(token: AnyToken): void; /** * Records a lifecycle event for tracking. */ recordLifecycleEvent(token: AnyToken, event: 'created' | 'initialized' | 'destroyed', instanceName: string): void; /** * Asserts that a service's onServiceInit was called. */ expectInitialized(token: AnyToken): void; /** * Asserts that a service's onServiceDestroy was called. */ expectDestroyed(token: AnyToken): void; /** * Asserts that a service has NOT been destroyed. */ expectNotDestroyed(token: AnyToken): void; /** * Asserts that a method was called on a service. */ expectCalled(token: AnyToken, method: string): void; /** * Asserts that a method was NOT called on a service. */ expectNotCalled(token: AnyToken, method: string): void; /** * Asserts that a method was called with specific arguments. */ expectCalledWith(token: AnyToken, method: string, expectedArgs: unknown[]): void; /** * Asserts that a method was called a specific number of times. */ expectCallCount(token: AnyToken, method: string, count: number): void; /** * Gets all recorded method calls for a service. */ getMethodCalls(token: AnyToken): MethodCallRecord[]; /** * Gets statistics about a service. */ getServiceStats(token: AnyToken): MockServiceStats; /** * Clears all recorded method calls. */ clearMethodCalls(): void; /** * Gets list of all registered provider token IDs. */ getRegisteredTokenIds(): ReadonlySet; /** * Gets list of all auto-mocked token IDs. */ getAutoMockedTokenIds(): ReadonlySet; private resolveToken; private registerProvider; private registerValueBinding; private registerClassBinding; private registerFactoryBinding; private argsMatch; } //#endregion export { BindingBuilder, DependencyGraph, DependencyNode, LifecycleRecord, MethodCallRecord, MockServiceStats, ProviderConfig, TestContainer, TestContainerOptions, UnitTestContainer, UnitTestContainerOptions }; //# sourceMappingURL=index.d.cts.map