mirror of
https://github.com/MasterAcnolo/Freedom-Loader.git
synced 2026-11-13 15:09:20 +01:00
39 lines
1.1 KiB
JavaScript
39 lines
1.1 KiB
JavaScript
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();
|
|
});
|
|
});
|