mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-11-13 15:09:20 +01:00
feat: add UI toast notification for missing Firefox browser
This commit is contained in:
38
test/unit/toastNotifier.test.js
Normal file
38
test/unit/toastNotifier.test.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const mockSend = jest.fn();
|
||||
const mockGetMainWindow = jest.fn();
|
||||
|
||||
jest.mock("../../app/windowManager", () => ({
|
||||
getMainWindow: mockGetMainWindow,
|
||||
}));
|
||||
|
||||
const {sendToast} = require("../../app/toastNotifier");
|
||||
|
||||
describe("toastNotifier", () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
test("sends a toast to the active renderer", () => {
|
||||
mockGetMainWindow.mockReturnValue({
|
||||
isDestroyed: () => false,
|
||||
webContents: {
|
||||
isDestroyed: () => false,
|
||||
send: mockSend,
|
||||
},
|
||||
});
|
||||
|
||||
expect(sendToast("Firefox is missing", "error", 5000)).toBe(true);
|
||||
expect(mockSend).toHaveBeenCalledWith("show-toast", {
|
||||
message: "Firefox is missing",
|
||||
type: "error",
|
||||
duration: 5000,
|
||||
});
|
||||
});
|
||||
|
||||
test("does not throw when the renderer is unavailable", () => {
|
||||
mockGetMainWindow.mockReturnValue(null);
|
||||
|
||||
expect(sendToast("Firefox is missing", "error")).toBe(false);
|
||||
expect(mockSend).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user