Add failing spec for Menu.buildFromTemplate
This commit is contained in:
parent
e1d7ef7e24
commit
f178787737
2 changed files with 13 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
assert = require 'assert'
|
||||
|
||||
{remote} = require 'electron'
|
||||
{remote, ipcRenderer} = require 'electron'
|
||||
{Menu, MenuItem} = remote.require 'electron'
|
||||
|
||||
describe 'menu module', ->
|
||||
|
@ -9,6 +9,11 @@ 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 [
|
||||
|
|
|
@ -3,6 +3,7 @@ const app = electron.app;
|
|||
const ipcMain = electron.ipcMain;
|
||||
const dialog = electron.dialog;
|
||||
const BrowserWindow = electron.BrowserWindow;
|
||||
const Menu = electron.Menu;
|
||||
|
||||
const path = require('path');
|
||||
|
||||
|
@ -100,4 +101,10 @@ app.on('ready', function() {
|
|||
});
|
||||
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;
|
||||
})
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue