From 93cbe6539f601f8cc643cd84a7cbeb44ebe6e772 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Tue, 21 Jun 2016 15:59:02 -0700 Subject: [PATCH] Add spec for invalid menu item type --- lib/browser/api/menu-item.js | 2 +- spec/api-menu-spec.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/browser/api/menu-item.js b/lib/browser/api/menu-item.js index 25d52f8..b805792 100644 --- a/lib/browser/api/menu-item.js +++ b/lib/browser/api/menu-item.js @@ -70,7 +70,7 @@ const MenuItem = function (options) { this.overrideProperty('checked', false) if (!MenuItem.types.includes(this.type)) { - throw new Error(`Unknown menu type ${this.type}`) + throw new Error(`Unknown menu item type: ${this.type}`) } this.commandId = ++nextCommandId diff --git a/spec/api-menu-spec.js b/spec/api-menu-spec.js index a8cc5b5..a9cf511 100644 --- a/spec/api-menu-spec.js +++ b/spec/api-menu-spec.js @@ -359,4 +359,17 @@ describe('menu module', function () { } }) }) + + describe('MenuItem with invalid type', function () { + it('throws an exception', function () { + assert.throws(function () { + var menu = Menu.buildFromTemplate([ + { + label: 'text', + type: 'not-a-type' + } + ]) + }, /Unknown menu item type: not-a-type/) + }) + }) }) -- 2.7.4