test(window): cover dark native theme in main process
Extend the Electron main-process mock with nativeTheme and verify startup forces the dark title-bar contract.
This commit is contained in:
@@ -7,6 +7,7 @@ const electron = vi.hoisted(() => {
|
|||||||
const handlers = new Map<string, (...args: unknown[]) => void>();
|
const handlers = new Map<string, (...args: unknown[]) => void>();
|
||||||
return {
|
return {
|
||||||
handlers,
|
handlers,
|
||||||
|
nativeTheme: { themeSource: "system" },
|
||||||
app: {
|
app: {
|
||||||
isPackaged: false,
|
isPackaged: false,
|
||||||
getPath: vi.fn(() => "C:\\MDD\\Test"),
|
getPath: vi.fn(() => "C:\\MDD\\Test"),
|
||||||
@@ -30,6 +31,7 @@ vi.mock("electron", () => ({
|
|||||||
dialog: {},
|
dialog: {},
|
||||||
ipcMain: { handle: vi.fn(), on: vi.fn() },
|
ipcMain: { handle: vi.fn(), on: vi.fn() },
|
||||||
Menu: { buildFromTemplate: vi.fn(), setApplicationMenu: vi.fn() },
|
Menu: { buildFromTemplate: vi.fn(), setApplicationMenu: vi.fn() },
|
||||||
|
nativeTheme: electron.nativeTheme,
|
||||||
safeStorage: { isEncryptionAvailable: () => false, encryptString: vi.fn(), decryptString: vi.fn() },
|
safeStorage: { isEncryptionAvailable: () => false, encryptString: vi.fn(), decryptString: vi.fn() },
|
||||||
shell: { openExternal: vi.fn() },
|
shell: { openExternal: vi.fn() },
|
||||||
Tray: class {}
|
Tray: class {}
|
||||||
@@ -255,6 +257,7 @@ describe("main shutdown lifecycle", () => {
|
|||||||
|
|
||||||
it("prevents quit once, waits for shutdown, then allows exactly one loop-free quit", async () => {
|
it("prevents quit once, waits for shutdown, then allows exactly one loop-free quit", async () => {
|
||||||
const main = await import("../src/main/main");
|
const main = await import("../src/main/main");
|
||||||
|
expect(electron.nativeTheme.themeSource).toBe("dark");
|
||||||
const shutdown = deferred();
|
const shutdown = deferred();
|
||||||
const cleanup = vi.fn();
|
const cleanup = vi.fn();
|
||||||
const continueQuit = vi.fn();
|
const continueQuit = vi.fn();
|
||||||
|
|||||||
Reference in New Issue
Block a user