Files
spark-store/src/__tests__/unit/update-center/main-window-close-guard.test.ts
T
momen 0b17ada45a feat(update-center): 实现集中式软件更新中心功能
新增更新中心模块,支持管理 APM 和传统 deb 软件更新任务
- 添加更新任务队列管理、状态跟踪和日志记录功能
- 实现更新项忽略配置持久化存储
- 新增更新确认对话框和迁移提示
- 优化主窗口关闭时的任务保护机制
- 添加单元测试覆盖核心逻辑
2026-04-09 08:19:51 +08:00

45 lines
1.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
getMainWindowCloseAction,
shouldPreventMainWindowClose,
} from "../../../../electron/main/window-close-guard";
describe("main window close guard", () => {
it("keeps the app alive while update-center work is running", () => {
expect(
shouldPreventMainWindowClose({
installTaskCount: 0,
hasRunningUpdateCenterTasks: true,
}),
).toBe(true);
});
it("allows close only when both install and update-center work are idle", () => {
expect(
shouldPreventMainWindowClose({
installTaskCount: 0,
hasRunningUpdateCenterTasks: false,
}),
).toBe(false);
});
it("returns a hide action while any guarded work is active", () => {
expect(
getMainWindowCloseAction({
installTaskCount: 1,
hasRunningUpdateCenterTasks: false,
}),
).toBe("hide");
});
it("returns a destroy action only when all guarded work is idle", () => {
expect(
getMainWindowCloseAction({
installTaskCount: 0,
hasRunningUpdateCenterTasks: false,
}),
).toBe("destroy");
});
});