Files
Termix/scripts/electron-app-quit.test.ts
T

29 lines
824 B
TypeScript
Raw Normal View History

+5
2026-08-19 14:12:06 -05:00
import { createRequire } from "node:module";
import { describe, expect, it, vi } from "vitest";
const require = createRequire(import.meta.url);
const { quitApp } = require("../electron/app-quit.cjs") as {
quitApp: (
app: { quit: () => void },
window: { destroy: () => void } | null,
) => void;
};
describe("Electron app quit", () => {
it("destroys the window before quitting so renderer unload guards cannot cancel it", () => {
const calls: string[] = [];
quitApp(
{ quit: vi.fn(() => calls.push("quit")) },
{ destroy: vi.fn(() => calls.push("destroy")) },
);
expect(calls).toEqual(["destroy", "quit"]);
});
it("still quits after the window has already gone", () => {
const quit = vi.fn();
quitApp({ quit }, null);
expect(quit).toHaveBeenCalledOnce();
});
});