import type { SinonSandbox, SinonStub } from 'sinon'; import type { CommandDefinitionBuilder } from '../CommandDefinitionBuilder/CommandDefinitionBuilder.impl.js'; import type { Service } from '../core/Service/Service.impl.js'; import type { CommandFunctionContext } from '../core/types/commandType/CommandFunctionContext.js'; import type { FromEmitToOtherType } from '../core/types/FromEmitToOtherType.js'; import type { GetMessageParamsType } from '../core/types/GetMessageParamsType.js'; import type { GetMessagePayloadType } from '../core/types/GetMessagePayloadType.js'; import type { ServiceClass } from '../core/types/ServiceClass.js'; import type { ServiceClassMetrics } from '../core/types/ServiceClassMetrics.js'; /** * Infer the internal builder type configuration from a command builder. * * @group Unit test helper */ export type CommandContextMockBuilderTypes = T extends CommandDefinitionBuilder ? C : never; export type CommandContextMockServiceClass = T extends CommandDefinitionBuilder ? S : ServiceClass; export type CreateCommandContextMockInput> = { payload: GetMessagePayloadType['PayloadSchema'], CommandContextMockBuilderTypes['TransformInputPayloadSchema']>; parameter: GetMessageParamsType['ParamsSchema'], CommandContextMockBuilderTypes['TransformInputParamsSchema']>; sandbox?: SinonSandbox; resources?: Partial['Resources']>; message?: { payload: GetMessagePayloadType['PayloadSchema'], CommandContextMockBuilderTypes['TransformInputPayloadSchema']>; parameter: GetMessageParamsType['ParamsSchema'], CommandContextMockBuilderTypes['TransformInputParamsSchema']>; }; }; export type CommandContextMockResult> = { context: CommandFunctionContext['PayloadSchema'], CommandContextMockBuilderTypes['TransformInputPayloadSchema']>, GetMessageParamsType['ParamsSchema'], CommandContextMockBuilderTypes['TransformInputParamsSchema']>, CommandContextMockBuilderTypes['Resources'], CommandContextMockBuilderTypes['Invokes'], CommandContextMockBuilderTypes['StreamInvokes'], CommandContextMockBuilderTypes['EmitList'], CommandContextMockBuilderTypes['QueueInvokes'], ServiceClassMetrics>>; mock: CommandFunctionContext['PayloadSchema'], CommandContextMockBuilderTypes['TransformInputPayloadSchema']>, GetMessageParamsType['ParamsSchema'], CommandContextMockBuilderTypes['TransformInputParamsSchema']>, CommandContextMockBuilderTypes['Resources'], CommandContextMockBuilderTypes['Invokes'], CommandContextMockBuilderTypes['StreamInvokes'], CommandContextMockBuilderTypes['EmitList'], CommandContextMockBuilderTypes['QueueInvokes'], ServiceClassMetrics>>; stubs: { logger: Record; emit: FromEmitToOtherType['EmitList'], SinonStub>; invoke: SinonStub; wrapInSpan: SinonStub; startActiveSpan: SinonStub; getSecret: SinonStub; setSecret: SinonStub; removeSecret: SinonStub; getConfig: SinonStub; setConfig: SinonStub; removeConfig: SinonStub; getState: SinonStub; setState: SinonStub; removeState: SinonStub; enqueue: SinonStub; scheduleAt: SinonStub; service: Record; resources: Partial['Resources']>; }; }; /** * Create a typed command handler context mock from a command builder. * * Use this helper when you want to test command handler logic directly without * booting a full service instance. * * @example * ```ts * const { context, stubs } = createCommandContextMock(signUpCommandBuilder, { * payload: { email: 'user@example.com' }, * parameter: {}, * }) * * await signUp.call(service, context, { email: 'user@example.com' }, {}) * expect(stubs.emit.userSignedUp.called).toBe(true) * ``` * * @group Unit test helper */ export declare const createCommandContextMock: >(builder: TBuilder, input: CreateCommandContextMockInput) => CommandContextMockResult; //# sourceMappingURL=createCommandContextMock.d.ts.map