Skip to content

Commit 2ef8483

Browse files
committed
add test
1 parent da546b7 commit 2ef8483

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

packages/compass/src/main/menu.spec.ts

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import EventEmitter from 'events';
1+
import EventEmitter, { once } from 'events';
22
import type { MenuItemConstructorOptions } from 'electron';
33
import { BrowserWindow, ipcMain, Menu, app, dialog } from 'electron';
44
import { expect } from 'chai';
@@ -653,6 +653,25 @@ describe('CompassMenu', function () {
653653
]);
654654
});
655655

656+
it('does not crash when rendering menu item with an accelerator', async () => {
657+
const menu = Menu.buildFromTemplate([
658+
{
659+
label: 'Test Super',
660+
accelerator: 'Super+Ctrl+T',
661+
},
662+
{
663+
label: 'Test Meta',
664+
accelerator: 'Meta+Ctrl+T',
665+
},
666+
]);
667+
const menuWillClose = once(menu, 'menu-will-close');
668+
menu.popup({
669+
window: new BrowserWindow({ show: false, width: 100, height: 100 }),
670+
});
671+
menu.closePopup();
672+
await menuWillClose;
673+
});
674+
656675
it('should generate a menu template without collection submenu if `showCollection` is `false`', function () {
657676
expect(
658677
CompassMenu.getTemplate(0).find((item) => item.label === '&Collection')

0 commit comments

Comments
 (0)