mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-04-30 03:10:16 +08:00
update 尝试修复点击更新后无法推送到下载列表的问题
This commit is contained in:
36
src/__tests__/unit/processInstall.test.ts
Normal file
36
src/__tests__/unit/processInstall.test.ts
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||||
|
|
||||||
|
describe("processInstall queue forwarding", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.resetModules();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("forwards update-center queue-install events back to the main install queue", async () => {
|
||||||
|
const handlers = new Map<string, (...args: unknown[]) => void>();
|
||||||
|
const send = vi.fn();
|
||||||
|
const on = vi.fn(
|
||||||
|
(channel: string, handler: (...args: unknown[]) => void) => {
|
||||||
|
handlers.set(channel, handler);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
Object.assign(window.ipcRenderer, {
|
||||||
|
on,
|
||||||
|
send,
|
||||||
|
invoke: vi.fn(),
|
||||||
|
});
|
||||||
|
|
||||||
|
await import("@/modules/processInstall");
|
||||||
|
|
||||||
|
const payload = JSON.stringify({
|
||||||
|
id: 7,
|
||||||
|
pkgname: "spark-weather",
|
||||||
|
origin: "spark",
|
||||||
|
upgradeOnly: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
handlers.get("queue-install")?.({}, payload);
|
||||||
|
|
||||||
|
expect(send).toHaveBeenCalledWith("queue-install", payload);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -235,3 +235,9 @@ window.ipcRenderer.on("install-complete", (_event, log: DownloadResult) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.ipcRenderer.on("queue-install", (_event, payload: unknown) => {
|
||||||
|
const serializedPayload =
|
||||||
|
typeof payload === "string" ? payload : JSON.stringify(payload);
|
||||||
|
window.ipcRenderer.send("queue-install", serializedPayload);
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user