| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  | const chai = require('chai') | 
					
						
							|  |  |  | const dirtyChai = require('dirty-chai') | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-21 16:03:41 -07:00
										 |  |  | const {ipcRenderer, remote} = require('electron') | 
					
						
							| 
									
										
										
										
											2017-02-16 10:58:12 -08:00
										 |  |  | const {BrowserWindow, Menu, MenuItem} = remote | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  | const {sortMenuItems} = require('../lib/browser/api/menu-utils') | 
					
						
							| 
									
										
										
										
											2017-02-16 10:58:12 -08:00
										 |  |  | const {closeWindow} = require('./window-helpers') | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  | const {expect} = chai | 
					
						
							|  |  |  | chai.use(dirtyChai) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-27 16:45:58 -04:00
										 |  |  | describe('Menu module', () => { | 
					
						
							|  |  |  |   describe('Menu.buildFromTemplate', () => { | 
					
						
							|  |  |  |     it('should be able to attach extra fields', () => { | 
					
						
							| 
									
										
										
										
											2017-10-24 20:27:26 -04:00
										 |  |  |       const menu = Menu.buildFromTemplate([ | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |         { | 
					
						
							|  |  |  |           label: 'text', | 
					
						
							|  |  |  |           extra: 'field' | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 |  |  |       ]) | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |       expect(menu.items[0].extra).to.equal('field') | 
					
						
							| 
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 |  |  |     }) | 
					
						
							| 
									
										
										
										
											2016-02-16 17:09:41 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-27 16:45:58 -04:00
										 |  |  |     it('does not modify the specified template', () => { | 
					
						
							| 
									
										
										
										
											2018-02-23 08:53:59 -05:00
										 |  |  |       const template = [{label: 'text', submenu: [{label: 'sub'}]}] | 
					
						
							|  |  |  |       const result = ipcRenderer.sendSync('eval', `const template = [{label: 'text', submenu: [{label: 'sub'}]}]\nrequire('electron').Menu.buildFromTemplate(template)\ntemplate`) | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |       expect(result).to.deep.equal(template) | 
					
						
							| 
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 |  |  |     }) | 
					
						
							| 
									
										
										
										
											2016-02-16 17:09:41 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-27 16:45:58 -04:00
										 |  |  |     it('does not throw exceptions for undefined/null values', () => { | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |       expect(() => { | 
					
						
							| 
									
										
										
										
											2016-03-17 16:09:16 -07:00
										 |  |  |         Menu.buildFromTemplate([ | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             label: 'text', | 
					
						
							|  |  |  |             accelerator: undefined | 
					
						
							| 
									
										
										
										
											2016-03-17 16:14:31 -07:00
										 |  |  |           }, | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             label: 'text again', | 
					
						
							|  |  |  |             accelerator: null | 
					
						
							| 
									
										
										
										
											2016-03-17 16:09:16 -07:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 |  |  |         ]) | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |       }).to.not.throw() | 
					
						
							| 
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 |  |  |     }) | 
					
						
							| 
									
										
										
										
											2016-03-17 16:09:16 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |     describe('Menu sorting and building', () => { | 
					
						
							|  |  |  |       describe('sorts groups', () => { | 
					
						
							|  |  |  |         it('does a simple sort', () => { | 
					
						
							|  |  |  |           const items = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               label: 'two', | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               afterGroupContaining: ['1'] }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           const expected = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two', | 
					
						
							|  |  |  |               afterGroupContaining: ['1'] | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |           expect(sortMenuItems(items)).to.deep.equal(expected) | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         it('resolves cycles by ignoring things that conflict', () => { | 
					
						
							|  |  |  |           const items = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two', | 
					
						
							|  |  |  |               afterGroupContaining: ['1'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one', | 
					
						
							|  |  |  |               afterGroupContaining: ['2'] | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           const expected = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one', | 
					
						
							|  |  |  |               afterGroupContaining: ['2'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two', | 
					
						
							|  |  |  |               afterGroupContaining: ['1'] | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |           expect(sortMenuItems(items)).to.deep.equal(expected) | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         it('ignores references to commands that do not exist', () => { | 
					
						
							|  |  |  |           const items = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two', | 
					
						
							|  |  |  |               afterGroupContaining: ['does-not-exist'] | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           const expected = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two', | 
					
						
							|  |  |  |               afterGroupContaining: ['does-not-exist'] | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |           expect(sortMenuItems(items)).to.deep.equal(expected) | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         it('only respects the first matching [before|after]GroupContaining rule in a given group', () => { | 
					
						
							|  |  |  |           const items = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '3', | 
					
						
							|  |  |  |               label: 'three', | 
					
						
							|  |  |  |               beforeGroupContaining: ['1'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '4', | 
					
						
							|  |  |  |               label: 'four', | 
					
						
							|  |  |  |               afterGroupContaining: ['2'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two' | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           const expected = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '3', | 
					
						
							|  |  |  |               label: 'three', | 
					
						
							|  |  |  |               beforeGroupContaining: ['1'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '4', | 
					
						
							|  |  |  |               label: 'four', | 
					
						
							|  |  |  |               afterGroupContaining: ['2'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two' | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |           expect(sortMenuItems(items)).to.deep.equal(expected) | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |         }) | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       describe('moves an item to a different group by merging groups', () => { | 
					
						
							|  |  |  |         it('can move a group of one item', () => { | 
					
						
							|  |  |  |           const items = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '3', | 
					
						
							|  |  |  |               label: 'three', | 
					
						
							|  |  |  |               after: ['1'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           const expected = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '3', | 
					
						
							|  |  |  |               label: 'three', | 
					
						
							|  |  |  |               after: ['1'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two' | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |           expect(sortMenuItems(items)).to.deep.equal(expected) | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         it("moves all items in the moving item's group", () => { | 
					
						
							|  |  |  |           const items = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '3', | 
					
						
							|  |  |  |               label: 'three', | 
					
						
							|  |  |  |               after: ['1'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '4', | 
					
						
							|  |  |  |               label: 'four' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           const expected = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '3', | 
					
						
							|  |  |  |               label: 'three', | 
					
						
							|  |  |  |               after: ['1'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '4', | 
					
						
							|  |  |  |               label: 'four' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two' | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |           expect(sortMenuItems(items)).to.deep.equal(expected) | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         it("ignores positions relative to commands that don't exist", () => { | 
					
						
							|  |  |  |           const items = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '3', | 
					
						
							|  |  |  |               label: 'three', | 
					
						
							|  |  |  |               after: ['does-not-exist'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '4', | 
					
						
							|  |  |  |               label: 'four', | 
					
						
							|  |  |  |               after: ['1'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           const expected = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '3', | 
					
						
							|  |  |  |               label: 'three', | 
					
						
							|  |  |  |               after: ['does-not-exist'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '4', | 
					
						
							|  |  |  |               label: 'four', | 
					
						
							|  |  |  |               after: ['1'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two' | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |           expect(sortMenuItems(items)).to.deep.equal(expected) | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         it('can handle recursive group merging', () => { | 
					
						
							|  |  |  |           const items = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one', | 
					
						
							|  |  |  |               after: ['3'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two', | 
					
						
							|  |  |  |               before: ['1'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '3', | 
					
						
							|  |  |  |               label: 'three' | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           const expected = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '3', | 
					
						
							|  |  |  |               label: 'three' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two', | 
					
						
							|  |  |  |               before: ['1'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one', | 
					
						
							|  |  |  |               after: ['3'] | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |           expect(sortMenuItems(items)).to.deep.equal(expected) | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         it('can merge multiple groups when given a list of before/after commands', () => { | 
					
						
							|  |  |  |           const items = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '3', | 
					
						
							|  |  |  |               label: 'three', | 
					
						
							|  |  |  |               after: ['1', '2'] | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           const expected = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '3', | 
					
						
							|  |  |  |               label: 'three', | 
					
						
							|  |  |  |               after: ['1', '2'] | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |           expect(sortMenuItems(items)).to.deep.equal(expected) | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |         }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         it('can merge multiple groups based on both before/after commands', () => { | 
					
						
							|  |  |  |           const items = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { type: 'separator' }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '3', | 
					
						
							|  |  |  |               label: 'three', | 
					
						
							|  |  |  |               after: ['1'], | 
					
						
							|  |  |  |               before: ['2'] | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           const expected = [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '1', | 
					
						
							|  |  |  |               label: 'one' | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '3', | 
					
						
							|  |  |  |               label: 'three', | 
					
						
							|  |  |  |               after: ['1'], | 
					
						
							|  |  |  |               before: ['2'] | 
					
						
							|  |  |  |             }, | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               id: '2', | 
					
						
							|  |  |  |               label: 'two' | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |           expect(sortMenuItems(items)).to.deep.equal(expected) | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |         }) | 
					
						
							|  |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-27 16:45:58 -04:00
										 |  |  |       it('should position before existing item', () => { | 
					
						
							| 
									
										
										
										
											2017-10-24 20:27:26 -04:00
										 |  |  |         const menu = Menu.buildFromTemplate([ | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |           { | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |             id: '2', | 
					
						
							|  |  |  |             label: 'two' | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |           }, { | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |             id: '3', | 
					
						
							|  |  |  |             label: 'three' | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |           }, { | 
					
						
							|  |  |  |             id: '1', | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |             label: 'one', | 
					
						
							|  |  |  |             before: ['2'] | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 |  |  |         ]) | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |         expect(menu.items[0].label).to.equal('one') | 
					
						
							|  |  |  |         expect(menu.items[1].label).to.equal('two') | 
					
						
							|  |  |  |         expect(menu.items[2].label).to.equal('three') | 
					
						
							| 
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 |  |  |       }) | 
					
						
							| 
									
										
										
										
											2016-02-16 17:09:41 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-27 16:45:58 -04:00
										 |  |  |       it('should position after existing item', () => { | 
					
						
							| 
									
										
										
										
											2017-10-24 20:27:26 -04:00
										 |  |  |         const menu = Menu.buildFromTemplate([ | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |           { | 
					
						
							|  |  |  |             id: '2', | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |             label: 'two', | 
					
						
							|  |  |  |             after: ['1'] | 
					
						
							|  |  |  |           }, | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |           { | 
					
						
							|  |  |  |             id: '1', | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |             label: 'one' | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |           }, { | 
					
						
							|  |  |  |             id: '3', | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |             label: 'three' | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 |  |  |         ]) | 
					
						
							| 
									
										
										
										
											2018-02-05 12:55:12 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |         expect(menu.items[0].label).to.equal('one') | 
					
						
							|  |  |  |         expect(menu.items[1].label).to.equal('two') | 
					
						
							|  |  |  |         expect(menu.items[2].label).to.equal('three') | 
					
						
							| 
									
										
										
										
											2018-02-05 12:55:12 -05:00
										 |  |  |       }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       it('should filter excess menu separators', () => { | 
					
						
							|  |  |  |         const menuOne = Menu.buildFromTemplate([ | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             type: 'separator' | 
					
						
							|  |  |  |           }, { | 
					
						
							|  |  |  |             label: 'a' | 
					
						
							|  |  |  |           }, { | 
					
						
							|  |  |  |             label: 'b' | 
					
						
							|  |  |  |           }, { | 
					
						
							|  |  |  |             label: 'c' | 
					
						
							|  |  |  |           }, { | 
					
						
							|  |  |  |             type: 'separator' | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         ]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |         expect(menuOne.items).to.have.length(3) | 
					
						
							|  |  |  |         expect(menuOne.items[0].label).to.equal('a') | 
					
						
							|  |  |  |         expect(menuOne.items[1].label).to.equal('b') | 
					
						
							|  |  |  |         expect(menuOne.items[2].label).to.equal('c') | 
					
						
							| 
									
										
										
										
											2018-02-05 12:55:12 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |         const menuTwo = Menu.buildFromTemplate([ | 
					
						
							|  |  |  |           { | 
					
						
							|  |  |  |             type: 'separator' | 
					
						
							|  |  |  |           }, { | 
					
						
							|  |  |  |             type: 'separator' | 
					
						
							|  |  |  |           }, { | 
					
						
							|  |  |  |             label: 'a' | 
					
						
							|  |  |  |           }, { | 
					
						
							|  |  |  |             label: 'b' | 
					
						
							|  |  |  |           }, { | 
					
						
							|  |  |  |             label: 'c' | 
					
						
							|  |  |  |           }, { | 
					
						
							|  |  |  |             type: 'separator' | 
					
						
							|  |  |  |           }, { | 
					
						
							|  |  |  |             type: 'separator' | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         ]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |         expect(menuTwo.items).to.have.length(3) | 
					
						
							|  |  |  |         expect(menuTwo.items[0].label).to.equal('a') | 
					
						
							|  |  |  |         expect(menuTwo.items[1].label).to.equal('b') | 
					
						
							|  |  |  |         expect(menuTwo.items[2].label).to.equal('c') | 
					
						
							| 
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 |  |  |       }) | 
					
						
							| 
									
										
										
										
											2016-02-16 17:09:41 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |       it('should continue inserting items at next index when no specifier is present', () => { | 
					
						
							| 
									
										
										
										
											2017-10-24 20:27:26 -04:00
										 |  |  |         const menu = Menu.buildFromTemplate([ | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |           { | 
					
						
							|  |  |  |             id: '2', | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |             label: 'two' | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |           }, { | 
					
						
							|  |  |  |             id: '3', | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |             label: 'three' | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |           }, { | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |             id: '4', | 
					
						
							|  |  |  |             label: 'four' | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |           }, { | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |             id: '5', | 
					
						
							|  |  |  |             label: 'five' | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |           }, { | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |             id: '1', | 
					
						
							|  |  |  |             label: 'one', | 
					
						
							|  |  |  |             before: ['2'] | 
					
						
							| 
									
										
										
										
											2016-01-11 18:40:23 -08:00
										 |  |  |           } | 
					
						
							| 
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 |  |  |         ]) | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |         expect(menu.items[0].label).to.equal('one') | 
					
						
							|  |  |  |         expect(menu.items[1].label).to.equal('two') | 
					
						
							|  |  |  |         expect(menu.items[2].label).to.equal('three') | 
					
						
							|  |  |  |         expect(menu.items[3].label).to.equal('four') | 
					
						
							|  |  |  |         expect(menu.items[4].label).to.equal('five') | 
					
						
							| 
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 |  |  |       }) | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |   }) | 
					
						
							| 
									
										
										
										
											2016-02-16 17:09:41 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-27 16:45:58 -04:00
										 |  |  |   describe('Menu.getMenuItemById', () => { | 
					
						
							|  |  |  |     it('should return the item with the given id', () => { | 
					
						
							| 
									
										
										
										
											2017-10-24 20:27:26 -04:00
										 |  |  |       const menu = Menu.buildFromTemplate([ | 
					
						
							| 
									
										
										
										
											2017-09-26 20:05:51 -04:00
										 |  |  |         { | 
					
						
							|  |  |  |           label: 'View', | 
					
						
							|  |  |  |           submenu: [ | 
					
						
							|  |  |  |             { | 
					
						
							|  |  |  |               label: 'Enter Fullscreen', | 
					
						
							| 
									
										
										
										
											2018-05-05 09:37:29 -07:00
										 |  |  |               accelerator: 'ControlCommandF', | 
					
						
							| 
									
										
										
										
											2017-09-26 20:05:51 -04:00
										 |  |  |               id: 'fullScreen' | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |           ] | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       ]) | 
					
						
							|  |  |  |       const fsc = menu.getMenuItemById('fullScreen') | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |       expect(menu.items[0].submenu.items[0]).to.equal(fsc) | 
					
						
							| 
									
										
										
										
											2017-09-26 20:05:51 -04:00
										 |  |  |     }) | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-27 16:45:58 -04:00
										 |  |  |   describe('Menu.insert', () => { | 
					
						
							|  |  |  |     it('should store item in @items by its index', () => { | 
					
						
							| 
									
										
										
										
											2017-10-24 20:27:26 -04:00
										 |  |  |       const menu = Menu.buildFromTemplate([ | 
					
						
							| 
									
										
										
										
											2018-02-23 08:53:59 -05:00
										 |  |  |         {label: '1'}, | 
					
						
							|  |  |  |         {label: '2'}, | 
					
						
							|  |  |  |         {label: '3'} | 
					
						
							| 
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 |  |  |       ]) | 
					
						
							| 
									
										
										
										
											2017-10-24 22:40:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-24 20:27:26 -04:00
										 |  |  |       const item = new MenuItem({ label: 'inserted' }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 |  |  |       menu.insert(1, item) | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |       expect(menu.items[0].label).to.equal('1') | 
					
						
							|  |  |  |       expect(menu.items[1].label).to.equal('inserted') | 
					
						
							|  |  |  |       expect(menu.items[2].label).to.equal('2') | 
					
						
							|  |  |  |       expect(menu.items[3].label).to.equal('3') | 
					
						
							| 
									
										
										
										
											2016-03-25 13:03:49 -07:00
										 |  |  |     }) | 
					
						
							|  |  |  |   }) | 
					
						
							| 
									
										
										
										
											2016-02-16 17:09:41 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-27 16:45:58 -04:00
										 |  |  |   describe('Menu.append', () => { | 
					
						
							|  |  |  |     it('should add the item to the end of the menu', () => { | 
					
						
							| 
									
										
										
										
											2017-10-24 22:40:31 -04:00
										 |  |  |       const menu = Menu.buildFromTemplate([ | 
					
						
							| 
									
										
										
										
											2018-02-23 08:53:59 -05:00
										 |  |  |         {label: '1'}, | 
					
						
							|  |  |  |         {label: '2'}, | 
					
						
							|  |  |  |         {label: '3'} | 
					
						
							| 
									
										
										
										
											2017-10-24 22:40:31 -04:00
										 |  |  |       ]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-23 08:53:59 -05:00
										 |  |  |       const item = new MenuItem({ label: 'inserted' }) | 
					
						
							| 
									
										
										
										
											2017-10-24 22:40:31 -04:00
										 |  |  |       menu.append(item) | 
					
						
							| 
									
										
										
										
											2018-02-23 08:53:59 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |       expect(menu.items[0].label).to.equal('1') | 
					
						
							|  |  |  |       expect(menu.items[1].label).to.equal('2') | 
					
						
							|  |  |  |       expect(menu.items[2].label).to.equal('3') | 
					
						
							|  |  |  |       expect(menu.items[3].label).to.equal('inserted') | 
					
						
							| 
									
										
										
										
											2017-10-24 22:40:31 -04:00
										 |  |  |     }) | 
					
						
							|  |  |  |   }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-27 12:38:55 -05:00
										 |  |  |   describe('Menu.popup', () => { | 
					
						
							| 
									
										
										
										
											2017-02-16 10:58:12 -08:00
										 |  |  |     let w = null | 
					
						
							| 
									
										
										
										
											2017-10-24 20:27:26 -04:00
										 |  |  |     let menu | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     beforeEach(() => { | 
					
						
							|  |  |  |       w = new BrowserWindow({show: false, width: 200, height: 200}) | 
					
						
							|  |  |  |       menu = Menu.buildFromTemplate([ | 
					
						
							| 
									
										
										
										
											2018-02-23 08:53:59 -05:00
										 |  |  |         {label: '1'}, | 
					
						
							|  |  |  |         {label: '2'}, | 
					
						
							|  |  |  |         {label: '3'} | 
					
						
							| 
									
										
										
										
											2017-10-24 20:27:26 -04:00
										 |  |  |       ]) | 
					
						
							|  |  |  |     }) | 
					
						
							| 
									
										
										
										
											2017-02-16 10:58:12 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-24 20:27:26 -04:00
										 |  |  |     afterEach(() => { | 
					
						
							| 
									
										
										
										
											2017-12-12 12:23:02 -08:00
										 |  |  |       menu.closePopup() | 
					
						
							|  |  |  |       menu.closePopup(w) | 
					
						
							| 
									
										
										
										
											2017-10-27 16:45:58 -04:00
										 |  |  |       return closeWindow(w).then(() => { w = null }) | 
					
						
							| 
									
										
										
										
											2017-02-16 10:58:12 -08:00
										 |  |  |     }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-17 06:31:10 +09:00
										 |  |  |     it('throws an error if options is not an object', () => { | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |       expect(() => { | 
					
						
							| 
									
										
										
										
											2018-03-17 06:31:10 +09:00
										 |  |  |         menu.popup() | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |       }).to.throw(/Options must be an object/) | 
					
						
							| 
									
										
										
										
											2018-03-17 06:31:10 +09:00
										 |  |  |     }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-27 11:23:46 -05:00
										 |  |  |     it('should emit menu-will-show event', (done) => { | 
					
						
							|  |  |  |       menu.on('menu-will-show', () => { done() }) | 
					
						
							| 
									
										
										
										
											2018-02-20 14:02:24 -06:00
										 |  |  |       menu.popup({window: w}) | 
					
						
							| 
									
										
										
										
											2018-01-27 11:23:46 -05:00
										 |  |  |     }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('should emit menu-will-close event', (done) => { | 
					
						
							| 
									
										
										
										
											2018-01-27 12:36:51 -05:00
										 |  |  |       menu.on('menu-will-close', () => { done() }) | 
					
						
							| 
									
										
										
										
											2018-02-20 14:02:24 -06:00
										 |  |  |       menu.popup({window: w}) | 
					
						
							| 
									
										
										
										
											2018-01-27 11:23:46 -05:00
										 |  |  |       menu.closePopup() | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-14 00:13:45 +03:00
										 |  |  |     it('returns immediately', () => { | 
					
						
							| 
									
										
										
										
											2018-02-20 18:35:39 -06:00
										 |  |  |       const input = {window: w, x: 100, y: 101} | 
					
						
							|  |  |  |       const output = menu.popup(input) | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |       expect(output.x).to.equal(input.x) | 
					
						
							|  |  |  |       expect(output.y).to.equal(input.y) | 
					
						
							|  |  |  |       expect(output.browserWindow).to.equal(input.window) | 
					
						
							| 
									
										
										
										
											2017-12-11 13:54:43 -08:00
										 |  |  |     }) | 
					
						
							| 
									
										
										
										
											2017-12-08 14:52:21 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     it('works without a given BrowserWindow and options', () => { | 
					
						
							| 
									
										
										
										
											2018-02-23 08:53:59 -05:00
										 |  |  |       const {browserWindow, x, y} = menu.popup({x: 100, y: 101}) | 
					
						
							| 
									
										
										
										
											2017-12-11 13:54:43 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |       expect(browserWindow.constructor.name).to.equal('BrowserWindow') | 
					
						
							|  |  |  |       expect(x).to.equal(100) | 
					
						
							|  |  |  |       expect(y).to.equal(101) | 
					
						
							| 
									
										
										
										
											2017-12-08 14:52:21 -08:00
										 |  |  |     }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-19 20:59:47 -05:00
										 |  |  |     it('works with a given BrowserWindow, options and callback', (done) => { | 
					
						
							| 
									
										
										
										
											2018-02-20 11:10:53 -05:00
										 |  |  |       const {x, y} = menu.popup({ | 
					
						
							|  |  |  |         window: w, | 
					
						
							|  |  |  |         x: 100, | 
					
						
							|  |  |  |         y: 101, | 
					
						
							|  |  |  |         callback: () => done() | 
					
						
							|  |  |  |       }) | 
					
						
							| 
									
										
										
										
											2017-12-11 13:54:43 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |       expect(x).to.equal(100) | 
					
						
							|  |  |  |       expect(y).to.equal(101) | 
					
						
							| 
									
										
										
										
											2018-02-19 13:15:49 -05:00
										 |  |  |       menu.closePopup() | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('works with a given BrowserWindow, no options, and a callback', (done) => { | 
					
						
							| 
									
										
										
										
											2018-02-20 11:10:53 -05:00
										 |  |  |       menu.popup({window: w, callback: () => done()}) | 
					
						
							| 
									
										
										
										
											2018-01-01 17:17:01 +09:00
										 |  |  |       menu.closePopup() | 
					
						
							|  |  |  |     }) | 
					
						
							| 
									
										
										
										
											2017-02-16 10:58:12 -08:00
										 |  |  |   }) | 
					
						
							| 
									
										
										
										
											2017-10-24 22:40:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-27 16:45:58 -04:00
										 |  |  |   describe('Menu.setApplicationMenu', () => { | 
					
						
							| 
									
										
										
										
											2017-11-07 13:29:37 -08:00
										 |  |  |     it('sets a menu', () => { | 
					
						
							|  |  |  |       const menu = Menu.buildFromTemplate([ | 
					
						
							| 
									
										
										
										
											2018-02-23 08:53:59 -05:00
										 |  |  |         {label: '1'}, | 
					
						
							|  |  |  |         {label: '2'} | 
					
						
							| 
									
										
										
										
											2017-11-07 13:29:37 -08:00
										 |  |  |       ]) | 
					
						
							| 
									
										
										
										
											2018-02-23 08:53:59 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-07 13:29:37 -08:00
										 |  |  |       Menu.setApplicationMenu(menu) | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |       expect(Menu.getApplicationMenu()).to.not.be.null() | 
					
						
							| 
									
										
										
										
											2017-11-07 13:29:37 -08:00
										 |  |  |     }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     it('unsets a menu with null', () => { | 
					
						
							|  |  |  |       Menu.setApplicationMenu(null) | 
					
						
							| 
									
										
										
										
											2018-06-30 00:25:28 -07:00
										 |  |  |       expect(Menu.getApplicationMenu()).to.be.null() | 
					
						
							| 
									
										
										
										
											2017-11-07 13:29:37 -08:00
										 |  |  |     }) | 
					
						
							| 
									
										
										
										
											2017-10-24 22:40:31 -04:00
										 |  |  |   }) | 
					
						
							| 
									
										
										
										
											2016-10-05 12:24:08 -07:00
										 |  |  | }) |