assert = require 'assert'
-{remote} = require 'electron'
+{remote, ipcRenderer} = require 'electron'
{Menu, MenuItem} = remote.require 'electron'
describe 'menu module', ->
menu = Menu.buildFromTemplate [label: 'text', extra: 'field']
assert.equal menu.items[0].extra, 'field'
+ it 'does not modify the specified template', ->
+ template = [label: 'text', submenu: [label: 'sub']]
+ builtTemplate = ipcRenderer.sendSync('menu-build-from-template', template)
+ assert.deepStrictEqual builtTemplate, template
+
describe 'Menu.buildFromTemplate should reorder based on item position specifiers', ->
it 'should position before existing item', ->
menu = Menu.buildFromTemplate [
const ipcMain = electron.ipcMain;
const dialog = electron.dialog;
const BrowserWindow = electron.BrowserWindow;
+const Menu = electron.Menu;
const path = require('path');
});
event.returnValue = "done";
});
+
+ // Verify Menu.buildFromTemplate does not modify the specified template
+ ipcMain.on('menu-build-from-template', function(event, template) {
+ Menu.buildFromTemplate(template);
+ event.returnValue = template;
+ })
});