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