Skip to content

Commit

Permalink
Adding error notification as suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcottner committed Nov 30, 2023
1 parent 09b3998 commit e477f13
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/sagas/signoff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export function* onCollectionRecordsRequest(
console.warn(ex);
} else {
console.error(ex);
notifyError("Error received when requesting signoff info from server.");
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion test/sagas/signoff_test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { call, put } from "redux-saga/effects";
import { notifySuccess } from "../../src/actions/notifications";
import { notifySuccess, notifyError } from "../../src/actions/notifications";
import { routeLoadSuccess } from "../../src/actions/route";
import { setClient } from "../../src/client";
import * as actions from "../../src/actions/signoff";
import * as collection_actions from "../../src/actions/collection";
import * as saga from "../../src/sagas/signoff";

jest.mock("../../src/actions/notifications", () => {
const original = jest.requireActual("../../src/actions/notifications");
return {
...original,
notifyError: jest.fn(),
};
});

describe("Signoff sagas", () => {
describe("list hook", () => {
let getState;
Expand Down Expand Up @@ -225,6 +233,7 @@ describe("Signoff sagas", () => {
expect(result.next().value).toBeUndefined();
expect(console.warn).toHaveBeenCalledTimes(1);
expect(console.error).toHaveBeenCalledTimes(0);
expect(notifyError).toHaveBeenCalledTimes(0);
});

it("Should catch and log an error if an error (not 401) response is received", () => {
Expand All @@ -246,6 +255,7 @@ describe("Signoff sagas", () => {
expect(result.next().value).toBeUndefined();
expect(console.warn).toHaveBeenCalledTimes(0);
expect(console.error).toHaveBeenCalledTimes(1);
expect(notifyError).toHaveBeenCalledTimes(1);
});
});
});
Expand Down

0 comments on commit e477f13

Please sign in to comment.