fix: more work on menus

This commit is contained in:
2026-02-17 11:25:50 +01:00
parent 7b5829e965
commit 70bc0b1b09
7 changed files with 442 additions and 33 deletions

View File

@@ -16,6 +16,9 @@ const registeredHandlers = new Map<string, (...args: any[]) => Promise<any>>();
// Mock ipcMain to capture handler registrations
vi.mock('electron', () => ({
app: {
quit: vi.fn(),
},
ipcMain: {
handle: vi.fn((channel: string, handler: (...args: any[]) => Promise<any>) => {
registeredHandlers.set(channel, handler);
@@ -27,6 +30,7 @@ vi.mock('electron', () => ({
},
shell: {
openPath: vi.fn(),
openExternal: vi.fn(),
showItemInFolder: vi.fn(),
},
}));
@@ -1371,6 +1375,28 @@ describe('IPC Handlers', () => {
expect(toggleDevTools).toHaveBeenCalled();
expect(send).not.toHaveBeenCalled();
});
it('should quit the application when action is quit', async () => {
const { app } = await import('electron');
const send = vi.fn();
const event = { sender: { send } };
await invokeHandlerWithEvent(event, 'app:triggerMenuAction', 'quit');
expect(app.quit).toHaveBeenCalled();
expect(send).not.toHaveBeenCalled();
});
it('should open repository URL when action is viewOnGitHub', async () => {
const { shell } = await import('electron');
const send = vi.fn();
const event = { sender: { send } };
await invokeHandlerWithEvent(event, 'app:triggerMenuAction', 'viewOnGitHub');
expect(shell.openExternal).toHaveBeenCalledWith('https://github.com/rfc1437/bDS');
expect(send).not.toHaveBeenCalled();
});
});
});