mirror of
https://github.com/YuzuZensai/Termix.git
synced 2026-09-13 10:49:03 +00:00
29 lines
824 B
TypeScript
29 lines
824 B
TypeScript
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();
|
||
|
|
});
|
||
|
|
});
|