From f7bc5481f386db241ba9f3dfac5bb0c63e7a183e Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 24 Oct 2017 22:40:31 -0400 Subject: [PATCH] add a few more tests to api_menu_spec --- spec/api-menu-spec.js | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/spec/api-menu-spec.js b/spec/api-menu-spec.js index fa389fe5f7da..ad2ddafeb732 100644 --- a/spec/api-menu-spec.js +++ b/spec/api-menu-spec.js @@ -4,7 +4,7 @@ const {ipcRenderer, remote} = require('electron') const {BrowserWindow, Menu, MenuItem} = remote const {closeWindow} = require('./window-helpers') -describe('menu module', function () { +describe.only('menu module', function () { describe('Menu.buildFromTemplate', function () { it('should be able to attach extra fields', function () { const menu = Menu.buildFromTemplate([ @@ -229,6 +229,7 @@ describe('menu module', function () { label: '3' } ]) + const item = new MenuItem({ label: 'inserted' }) menu.insert(1, item) @@ -239,6 +240,27 @@ describe('menu module', function () { }) }) + describe('Menu.append', function () { + it('should add the item to the end of the menu', function () { + const menu = Menu.buildFromTemplate([ + { + label: '1' + }, { + label: '2' + }, { + label: '3' + } + ]) + const item = new MenuItem({ label: 'inserted' }) + + menu.append(item) + assert.equal(menu.items[0].label, '1') + assert.equal(menu.items[1].label, '2') + assert.equal(menu.items[2].label, '3') + assert.equal(menu.items[3].label, 'inserted') + }) + }) + describe('Menu.popup', function () { let w = null let menu @@ -267,6 +289,19 @@ describe('menu module', function () { }) }) }) + + describe('Menu.setApplicationMenu', function () { + const menu = Menu.buildFromTemplate([ + { + label: '1' + }, { + label: '2' + } + ]) + Menu.setApplicationMenu(menu) + assert.notEqual(Menu.getApplicationMenu(), null) + }) + describe('MenuItem.click', function () { it('should be called with the item object passed', function (done) { const menu = Menu.buildFromTemplate([