Skip to content

Commit

Permalink
Actions: used simple object as error payload
Browse files Browse the repository at this point in the history
  • Loading branch information
Rolandkuku committed Dec 6, 2018
1 parent 385e719 commit 683eec7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function getGroup(resource, action) {
[`${action}_FAILURE`]: `${resource}_${action}_FAILURE`,
[`${funcName}Failure`]: (statusCode, data) => ({
type: `${resource}_${action}_FAILURE`,
payload: new Error({ statusCode, data }),
payload: { statusCode, data },
error: true,
}),
};
Expand Down
26 changes: 13 additions & 13 deletions src/tests/actions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("Redux api actions", () => {
expect(mojoActions.CREATE_FAILURE).toEqual("MOJO_CREATE_FAILURE");
expect(mojoActions.createFailure(400, "error")).toEqual({
type: mojoActions.CREATE_FAILURE,
payload: new Error({ data: "error", statusCode: 400 }),
payload: { data: "error", statusCode: 400 },
error: true,
});
});
Expand Down Expand Up @@ -97,10 +97,10 @@ describe("Redux api actions", () => {
expect(mojoActions.READ_FAILURE).toEqual("MOJO_READ_FAILURE");
expect(mojoActions.readFailure(400, "error.")).toEqual({
type: mojoActions.READ_FAILURE,
payload: new Error({
payload: {
data: "error.",
statusCode: 400,
}),
},
error: true,
});
});
Expand Down Expand Up @@ -135,10 +135,10 @@ describe("Redux api actions", () => {
expect(mojoActions.UPDATE_FAILURE).toEqual("MOJO_UPDATE_FAILURE");
expect(mojoActions.updateFailure(400, "Couldn't update.")).toEqual({
type: mojoActions.UPDATE_FAILURE,
payload: new Error({
payload: {
data: "Couldn't update.",
statusCode: 400,
}),
},
error: true,
});
});
Expand Down Expand Up @@ -173,10 +173,10 @@ describe("Redux api actions", () => {
expect(mojoActions.DELETE_FAILURE).toEqual("MOJO_DELETE_FAILURE");
expect(mojoActions.deleteFailure(400, "Couldn't delete.")).toEqual({
type: mojoActions.DELETE_FAILURE,
payload: new Error({
payload: {
data: "Couldn't delete.",
statusCode: 400,
}),
},
error: true,
});
});
Expand Down Expand Up @@ -211,10 +211,10 @@ describe("Redux api actions", () => {
expect(mojoActions.LIST_FAILURE).toEqual("MOJO_LIST_FAILURE");
expect(mojoActions.listFailure(400, "Couldn't list.")).toEqual({
type: mojoActions.LIST_FAILURE,
payload: new Error({
payload: {
data: "Couldn't list.",
statusCode: 400,
}),
},
error: true,
});
});
Expand Down Expand Up @@ -249,10 +249,10 @@ describe("Redux api actions", () => {
expect(mojoActions.POST_FAILURE).toEqual("MOJO_POST_FAILURE");
expect(mojoActions.postFailure(400, "Couldn't post.")).toEqual({
type: mojoActions.POST_FAILURE,
payload: new Error({
payload: {
data: "Couldn't post.",
statusCode: 400,
}),
},
error: true,
});
});
Expand Down Expand Up @@ -305,10 +305,10 @@ describe("Redux api actions", () => {
await mojoActions.create()(spy);
expect(spy).toHaveBeenCalledWith({
type: "MOJO_CREATE_FAILURE",
payload: new Error({
payload: {
data: "Not found.",
statusCode: 404,
}),
},
error: true,
});
});
Expand Down

0 comments on commit 683eec7

Please sign in to comment.