import { afterEach, describe, expect, it, vi } from "vitest"; import { DEFAULT_DESKTOP_SHORTCUTS } from "./desktopUiPreferences"; import { syncDesktopMenuShortcuts } from "./desktopMenu"; const invokeMock = vi.hoisted(() => vi.fn()); vi.mock("@tauri-apps/api/core", () => ({ invoke: invokeMock, })); afterEach(() => { invokeMock.mockReset(); Reflect.deleteProperty(window, "__TAURI_INTERNALS__"); }); describe("desktop native menu", () => { it("does not invoke desktop commands in the web runtime", async () => { await syncDesktopMenuShortcuts(DEFAULT_DESKTOP_SHORTCUTS); expect(invokeMock).not.toHaveBeenCalled(); }); it("synchronizes validated shortcut preferences through the controlled command", async () => { Object.defineProperty(window, "__TAURI_INTERNALS__", { value: {}, configurable: true }); await syncDesktopMenuShortcuts(DEFAULT_DESKTOP_SHORTCUTS); expect(invokeMock).toHaveBeenCalledWith("desktop_menu_set_shortcuts", { shortcuts: DEFAULT_DESKTOP_SHORTCUTS, }); }); });