mirror of
https://github.com/Termix-SSH/Termix.git
synced 2026-10-28 06:05:24 +00:00
fix: cover the gnome close path in the desktop quit test (#1332)
This commit is contained in:
1 parent
71bbec7084
commit
09259de01c
1 file changed
+21
-1
@@ -12,17 +12,26 @@ const shell = fs.readFileSync(
|
||||
"utf8",
|
||||
);
|
||||
|
||||
function harness(active = true, hasTray = true) {
|
||||
function harness(
|
||||
active = true,
|
||||
hasTray = true,
|
||||
platform: { platform: string; env: Record<string, string> } = {
|
||||
platform: "win32",
|
||||
env: {},
|
||||
},
|
||||
) {
|
||||
const app = new EventEmitter();
|
||||
const window = Object.assign(new EventEmitter(), {
|
||||
webContents: new EventEmitter(),
|
||||
hide: vi.fn(),
|
||||
minimize: vi.fn(),
|
||||
});
|
||||
const context = vm.createContext({
|
||||
isQuitting: false,
|
||||
app,
|
||||
mainWindow: window,
|
||||
console,
|
||||
process: platform,
|
||||
tray: hasTray ? { isDestroyed: () => false } : null,
|
||||
hasActiveConnection: () => active,
|
||||
});
|
||||
@@ -91,6 +100,17 @@ describe("desktop quit with active connections", () => {
|
||||
expect(event.preventDefault).toHaveBeenCalledOnce();
|
||||
expect(app.window.hide).toHaveBeenCalledOnce();
|
||||
});
|
||||
it("minimizes instead of hiding on GNOME, which has no tray by default", () => {
|
||||
const app = harness(true, true, {
|
||||
platform: "linux",
|
||||
env: { XDG_CURRENT_DESKTOP: "ubuntu:GNOME" },
|
||||
});
|
||||
const event = { preventDefault: vi.fn() };
|
||||
app.window.emit("close", event);
|
||||
expect(event.preventDefault).toHaveBeenCalledOnce();
|
||||
expect(app.window.minimize).toHaveBeenCalledOnce();
|
||||
expect(app.window.hide).not.toHaveBeenCalled();
|
||||
});
|
||||
it("quits normally when no connection blocks unloading", () => {
|
||||
expect(harness(false).attemptQuit()).toBe(true);
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user