test: add unit tests for configuration and download controllers and handle electron app initialization and improve devMode logic

This commit is contained in:
MasterAcnolo
2026-10-28 21:58:46 +01:00
parent f0f3018f80
commit f650770df7
9 changed files with 629 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
const mockShow = jest.fn();
const mockOn = jest.fn();
const mockOpenPath = jest.fn();
const mockOpenPath = jest.fn().mockResolvedValue("");
const mockOpenExternal = jest.fn();
jest.mock("electron", () => ({
@@ -71,13 +71,16 @@ describe("notify.helpers", () => {
expect(mockShow).toHaveBeenCalled();
});
test("opens folder when notification is clicked", () => {
test("opens folder when notification is clicked", (done) => {
notifyDownloadFinished("/downloads");
const callback = mockOn.mock.calls[0][1];
callback();
expect(shell.openPath).toHaveBeenCalledWith("/downloads");
setTimeout(() => {
expect(shell.openPath).toHaveBeenCalledWith("/downloads");
done();
}, 200);
});
});
@@ -101,7 +104,7 @@ describe("notify.helpers", () => {
callback();
expect(shell.openExternal).toHaveBeenCalledWith(
"https://youtube.com/shorts/cN9f4s1Mf88?si=519QCVd_-fzJqRf1"
"https://www.firefox.com/en-US/download/"
);
});
});
@@ -126,7 +129,7 @@ describe("notify.helpers", () => {
callback();
expect(shell.openExternal).toHaveBeenCalledWith(
"https://youtube.com/shorts/cN9f4s1Mf88?si=519QCVd_-fzJqRf1"
"https://www.firefox.com/en-US/download/"
);
});
});