Add spec for invalid menu item type
authorKevin Sawicki <kevinsawicki@gmail.com>
Tue, 21 Jun 2016 22:59:02 +0000 (15:59 -0700)
committerKevin Sawicki <kevinsawicki@gmail.com>
Wed, 22 Jun 2016 16:21:46 +0000 (09:21 -0700)
lib/browser/api/menu-item.js
spec/api-menu-spec.js

index 25d52f8..b805792 100644 (file)
@@ -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
index a8cc5b5..a9cf511 100644 (file)
@@ -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/)
+    })
+  })
 })