Skip to content

Commit

Permalink
fix: send data if fails (to on state change)
Browse files Browse the repository at this point in the history
  • Loading branch information
yarinvak committed Mar 31, 2020
1 parent 3dd4356 commit 066e59c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/types/state-machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class StateMachine {
await this.execute(result.newEvent, result.data);
} catch (e) {
this.currentState = event.failedState;
await this.onStateChange(this.currentState, result, e);
await this.onStateChange(this.currentState, {data}, e);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/types/state-machine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ describe("state machine tests", () => {
await stateMachine.execute("next", {bla: "bla"});

// assert
expect(onChanged).toBeCalledWith("fa", undefined, error);
expect(onChanged).toBeCalledWith("fa", {data: {bla: "bla"}}, error);
});

test("execute | handler execution is successful | the state is changed to success state", async () => {
Expand Down

0 comments on commit 066e59c

Please sign in to comment.