import * as vitest from 'vitest'; import Either from '@hexadrop/either'; import DomainError from '@hexadrop/error'; import CommandBus from './bus.js'; import Command from './command.js'; import '@hexadrop/types/class'; import '@hexadrop/types/primitives'; /** * @class VitestMockCommandBus * @implements CommandBus * @description Class representing a mock command bus for testing in Vitest. */ declare class VitestMockCommandBus implements CommandBus { /** * @property {Mock} dispatchSpy - A mock function for the dispatch method. */ readonly dispatchSpy: vitest.Mock<(..._commands: Command[]) => Promise>>; /** * This is a private static method that extracts data from a command. * It omits the 'commandId' property from the command object and returns the remaining properties. * If no command is provided, it returns an empty object. * * @template CommandType - A type that extends the Command interface. * @param {CommandType} command - The command object from which to extract data. This is optional. * @returns {Omit | {}} - An object that contains the properties of the command object, excluding 'commandId'. If no command is provided, an empty object is returned. */ private static getDataFromCommand; /** * @method assertDispatchedCommands * @description Method to assert that specific commands were dispatched. * @param {...Command[]} expectedCommands - The expected dispatched commands. */ assertDispatchedCommands(...expectedCommands: Command[]): void; /** * @method assertLastDispatchedCommand * @description Method to assert that a specific command was the last one dispatched. * @param {Command} expectedCommand - The expected last dispatched command. */ assertLastDispatchedCommand(expectedCommand: Command): void; /** * @method assertNotDispatchedCommand * @description Method to assert that no command was dispatched. */ assertNotDispatchedCommand(): void; /** * @method dispatch * @description Method to dispatch a command. * @param {Command} command - The command to be dispatched. * @returns {Either | Promise>} - The result of the command dispatch. */ dispatch(command: Command): Either | Promise>; } export { VitestMockCommandBus as default };