[#121] added error handler and snackbar

This commit is contained in:
Camille Moussu
2025-10-08 18:14:15 +02:00
committed by Benoit TELLIER
parent f498309f44
commit a00f179dbd
6 changed files with 187 additions and 51 deletions
@@ -0,0 +1,35 @@
import { EventErrorHandler } from "../../../src/components/Error/EventErrorHandler";
describe("EventErrorHandler", () => {
it("calls the callback when a new error is reported", () => {
const handler = new EventErrorHandler();
const callback = jest.fn();
handler.setErrorCallback(callback);
handler.reportError("123", "Something broke");
expect(callback).toHaveBeenCalledWith(["Something broke"]);
});
it("does not duplicate errors for same eventId", () => {
const handler = new EventErrorHandler();
const callback = jest.fn();
handler.setErrorCallback(callback);
handler.reportError("A", "Error 1");
handler.reportError("A", "Error 1 again");
expect(callback).toHaveBeenCalledTimes(1);
});
it("clears errors properly", () => {
const handler = new EventErrorHandler();
const callback = jest.fn();
handler.setErrorCallback(callback);
handler.reportError("A", "Error 1");
handler.clearAll();
expect(callback).toHaveBeenLastCalledWith([]);
});
});