add a few more tests to api_menu_spec

This commit is contained in:
Shelley Vohr 2017-10-24 22:40:31 -04:00
parent d54148de4e
commit f7bc5481f3
No known key found for this signature in database
GPG key ID: F13993A75599653C

View file

@ -4,7 +4,7 @@ const {ipcRenderer, remote} = require('electron')
const {BrowserWindow, Menu, MenuItem} = remote
const {closeWindow} = require('./window-helpers')
describe('menu module', function () {
describe.only('menu module', function () {
describe('Menu.buildFromTemplate', function () {
it('should be able to attach extra fields', function () {
const menu = Menu.buildFromTemplate([
@ -229,6 +229,7 @@ describe('menu module', function () {
label: '3'
}
])
const item = new MenuItem({ label: 'inserted' })
menu.insert(1, item)
@ -239,6 +240,27 @@ describe('menu module', function () {
})
})
describe('Menu.append', function () {
it('should add the item to the end of the menu', function () {
const menu = Menu.buildFromTemplate([
{
label: '1'
}, {
label: '2'
}, {
label: '3'
}
])
const item = new MenuItem({ label: 'inserted' })
menu.append(item)
assert.equal(menu.items[0].label, '1')
assert.equal(menu.items[1].label, '2')
assert.equal(menu.items[2].label, '3')
assert.equal(menu.items[3].label, 'inserted')
})
})
describe('Menu.popup', function () {
let w = null
let menu
@ -267,6 +289,19 @@ describe('menu module', function () {
})
})
})
describe('Menu.setApplicationMenu', function () {
const menu = Menu.buildFromTemplate([
{
label: '1'
}, {
label: '2'
}
])
Menu.setApplicationMenu(menu)
assert.notEqual(Menu.getApplicationMenu(), null)
})
describe('MenuItem.click', function () {
it('should be called with the item object passed', function (done) {
const menu = Menu.buildFromTemplate([