import { StubbedInstance, Type } from '@automock/types'; import { ConstantValue, IdentifierMetadata } from '@automock/common'; import { MocksContainer } from './mocks-container'; /** * Provides a reference to mock objects that have been mocked for testing * purposes within the test environment. * * @see https://automock.dev/api-reference/api/unitreference-api */ export interface UnitReference { /** * Retrieves a reference to the mocked object of a dependency corresponding to its type identifier. * * @since 2.0.0 * @template TDependency The type of the dependency being retrieved. * @param type The type representing the dependency. * @returns The mocked object corresponding to the provided type identifier. */ get(type: Type): StubbedInstance; /** * Retrieves a reference to the mocked object of a dependency corresponding to its type identifier * and metadata object. * * @since 2.1.0 * @template TDependency The type of the dependency being retrieved. * @param type The type representing the dependency. * @param identifierMetadata A metadata object that corresponds to the type identifier. * @returns StubbedInstance The mocked object corresponding to the provided * symbol-based token. */ get(type: Type, identifierMetadata: IdentifierMetadata): StubbedInstance; /** * Retrieves a reference to the mocked object of a dependency corresponding to a string-based token. * * @since 2.0.0 * @template TDependency The type of the dependency being retrieved. * @param token The string-based token representing the dependency. * @returns The mocked object corresponding to the provided string-based token. */ get(token: string): StubbedInstance; /** * Retrieves a reference to the mocked object of a dependency corresponding to a string-based * token and an identifier metadata object. * * @since 2.1.0 * @template TDependency The type of the dependency being retrieved. * @param token The symbol-based token representing the dependency. * @param identifierMetadata An accompanying metadata object for the token identifier. * @returns StubbedInstance The mocked object corresponding to the provided * symbol-based token. */ get(token: string, identifierMetadata: IdentifierMetadata): StubbedInstance; /** * Retrieves a reference to the mocked object of a dependency corresponding to a symbol-based token. * * @since 2.0.0 * @template TDependency The type of the dependency being retrieved. * @param token The symbol-based token representing the dependency. * @returns The mocked object corresponding to the provided symbol-based token. */ get(token: symbol): StubbedInstance; /** * Retrieves a reference to the mocked object of a dependency corresponding to a symbol-based * token and an identifier metadata object. * * @since 2.1.0 * @template TDependency The type of the dependency being retrieved. * @param token The symbol-based token representing the dependency. * @param identifierMetadata An accompanying metadata object for the token identifier. * @returns StubbedInstance The mocked object corresponding to the provided symbol-based token. */ get(token: symbol, identifierMetadata: IdentifierMetadata): StubbedInstance; /** * Retrieves a constant value corresponding to a string-based token. * * @since 2.0.0 * @template TValue The type of the constant value being retrieved. * @param token The string-based token representing the constant value. * @returns The constant value corresponding to the provided string-based token. */ get(token: string): TValue; /** * Retrieves a constant value corresponding to a symbol-based token. * * @since 2.0.0 * @template TValue The type of the constant value being retrieved. * @param token The symbol-based token representing the constant value. * @returns The constant value corresponding to the provided symbol-based token. */ get(token: symbol): TValue; /** * Retrieves a mocked object or a constant value of a dependency using its type, string, or symbol token. * * This method provides flexibility in retrieving dependencies by allowing various identifier types. * Depending on the identifier and the setup, it can return either a mocked object or a constant value. * * @since 2.1.0 * @template TDependency The type of the dependency being retrieved. * @template TValue The type of the constant value that might be returned. * @param identifier The token representing the dependency. It can be of type `Type`, `string`, or `symbol`. * @param identifierMetadata A corresponding metadata object for the token identifier. * @returns StubbedInstance The mocked instance corresponding to the provided identifier and metadata if exists. */ get(identifier: Type | string | symbol, identifierMetadata?: IdentifierMetadata): StubbedInstance; /** * Retrieves a mocked object or a constant value of a dependency using its type, string, or symbol token. * * This method provides flexibility in retrieving dependencies by allowing various identifier types. * Depending on the identifier and the setup, it can return either a mocked object or a constant value. * * @since 2.0.0 * @template TDependency The type of the dependency being retrieved. * @template TValue The type of the constant value that might be returned. * @param identifier The token representing the dependency. It can be of type `Type`, `string`, or `symbol`. * @returns The mocked instance or constant value corresponding to the provided identifier. */ get(identifier: Type | string | symbol): StubbedInstance | TValue; } export declare class UnitReference { private readonly mocksContainer; constructor(mocksContainer: MocksContainer); }