Add spec for invalid menu item type

This commit is contained in:
Kevin Sawicki 2016-06-21 15:59:02 -07:00
parent ca57f8a391
commit 93cbe6539f
2 changed files with 14 additions and 1 deletions

View 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

View 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/)
})
})
})