From 1454783450d7b1358901d56f384487ebb6a80bc2 Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Tue, 7 Nov 2017 13:29:14 -0800 Subject: [PATCH 1/4] :wrench: Check `menu` for being falsy --- lib/browser/api/menu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/browser/api/menu.js b/lib/browser/api/menu.js index caa65afbbf0..10e14d19024 100644 --- a/lib/browser/api/menu.js +++ b/lib/browser/api/menu.js @@ -133,7 +133,7 @@ Menu.sendActionToFirstResponder = bindings.sendActionToFirstResponder // set application menu with a preexisting menu Menu.setApplicationMenu = function (menu) { - if (!(menu || menu.constructor === Menu)) { + if (!(!menu || menu.constructor === Menu)) { throw new TypeError('Invalid menu') } From 07dea13c777fbd3e0a63ac09ce552fc2a079b617 Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Tue, 7 Nov 2017 13:29:37 -0800 Subject: [PATCH 2/4] =?UTF-8?q?:construction=5Fworker:=20Let=E2=80=99s=20a?= =?UTF-8?q?dd=20a=20spec!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/api-menu-spec.js | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/spec/api-menu-spec.js b/spec/api-menu-spec.js index 560af5c05a4..2a74fc7297a 100644 --- a/spec/api-menu-spec.js +++ b/spec/api-menu-spec.js @@ -291,15 +291,22 @@ describe('Menu module', () => { }) describe('Menu.setApplicationMenu', () => { - const menu = Menu.buildFromTemplate([ - { - label: '1' - }, { - label: '2' - } - ]) - Menu.setApplicationMenu(menu) - assert.notEqual(Menu.getApplicationMenu(), null) + it('sets a menu', () => { + const menu = Menu.buildFromTemplate([ + { + label: '1' + }, { + label: '2' + } + ]) + Menu.setApplicationMenu(menu) + assert.notEqual(Menu.getApplicationMenu(), null) + }) + + it('unsets a menu with null', () => { + Menu.setApplicationMenu(null) + assert.equal(Menu.getApplicationMenu(), null) + }) }) describe('MenuItem.click', () => { From 3dcde824859ba0e535dbd113e36b40f2931aefa6 Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Tue, 7 Nov 2017 18:26:10 -0800 Subject: [PATCH 3/4] :wrench: Make this easier to read --- lib/browser/api/menu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/browser/api/menu.js b/lib/browser/api/menu.js index 10e14d19024..ef7d6796f63 100644 --- a/lib/browser/api/menu.js +++ b/lib/browser/api/menu.js @@ -133,7 +133,7 @@ Menu.sendActionToFirstResponder = bindings.sendActionToFirstResponder // set application menu with a preexisting menu Menu.setApplicationMenu = function (menu) { - if (!(!menu || menu.constructor === Menu)) { + if (menu && menu.constructor !== Menu)) { throw new TypeError('Invalid menu') } From d475eaf0116fce8ef81861b63e6c12bf67ba18ae Mon Sep 17 00:00:00 2001 From: Felix Rieseberg Date: Tue, 7 Nov 2017 19:44:24 -0800 Subject: [PATCH 4/4] :wrench: One commit per character is now hot --- lib/browser/api/menu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/browser/api/menu.js b/lib/browser/api/menu.js index ef7d6796f63..33c324d4fa8 100644 --- a/lib/browser/api/menu.js +++ b/lib/browser/api/menu.js @@ -133,7 +133,7 @@ Menu.sendActionToFirstResponder = bindings.sendActionToFirstResponder // set application menu with a preexisting menu Menu.setApplicationMenu = function (menu) { - if (menu && menu.constructor !== Menu)) { + if (menu && menu.constructor !== Menu) { throw new TypeError('Invalid menu') }