Add spec for invalid menu item type
This commit is contained in:
		
					parent
					
						
							
								ca57f8a391
							
						
					
				
			
			
				commit
				
					
						93cbe6539f
					
				
			
		
					 2 changed files with 14 additions and 1 deletions
				
			
		|  | @ -70,7 +70,7 @@ const MenuItem = function (options) { | ||||||
|   this.overrideProperty('checked', false) |   this.overrideProperty('checked', false) | ||||||
| 
 | 
 | ||||||
|   if (!MenuItem.types.includes(this.type)) { |   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 |   this.commandId = ++nextCommandId | ||||||
|  |  | ||||||
|  | @ -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/) | ||||||
|  |     }) | ||||||
|  |   }) | ||||||
| }) | }) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Kevin Sawicki
				Kevin Sawicki