@hexadrop/command
Version:
Hexagonal architecture utils library
2 lines • 850 B
JavaScript
import i from"@hexadrop/either";import"@hexadrop/error";import{expect as o,vi as d}from"vitest";var e=class t{dispatchSpy=d.fn((...a)=>Promise.resolve(i.right()));static getDataFromCommand(a){if(!a)return{};let{commandId:r,...m}=a;return m}assertDispatchedCommands(...a){o(this.dispatchSpy).toHaveBeenCalled();let r=this.dispatchSpy.mock.calls.flat();o(r.length).toEqual(a.length),o(r.map(m=>t.getDataFromCommand(m))).toStrictEqual(a.map(m=>t.getDataFromCommand(m)))}assertLastDispatchedCommand(a){o(this.dispatchSpy).toHaveBeenCalled();let m=(this.dispatchSpy.mock.calls.at(-1)??[])[0];o(m).toBeDefined(),o(t.getDataFromCommand(m)).toStrictEqual(t.getDataFromCommand(a))}assertNotDispatchedCommand(){o(this.dispatchSpy).not.toHaveBeenCalled()}dispatch(a){return this.dispatchSpy(a)}};export{e as default};
//# sourceMappingURL=bus.mock-vitest.js.map