fix: more work on menus
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user