Added specs

This commit is contained in:
mst128256 2017-03-24 12:14:08 +01:00
parent 76ee7fda2b
commit 9e471d8f1c
3 changed files with 50 additions and 4 deletions

View file

@ -64,8 +64,8 @@ The `role` property can have following values:
* `zoomin` - Zoom in the focused page by 10%
* `zoomout` - Zoom out the focused page by 10%
* `menuEdit` - Whole default "Edit" menu (Undo,Copy, etc.)
* `menuWindow` - Whole default "Window" menu (Minimize, Close, etc.)
* `editMenu` - Whole default "Edit" menu (Undo, Copy, etc.)
* `windowMenu` - Whole default "Window" menu (Minimize, Close, etc.)
On macOS `role` can also have following additional values:

View file

@ -156,7 +156,7 @@ const roles = {
}
},
// submenu Edit (should fit both Mac & Windows)
menuEdit: {
editMenu: {
label: 'Edit',
submenu: [
{
@ -197,7 +197,7 @@ const roles = {
},
// submenu Window should be used for Mac only
menuWindow: {
windowMenu: {
label: 'Window',
submenu: [
{

View file

@ -455,6 +455,52 @@ describe('menu module', function () {
})
})
describe('MenuItem editMenu', function() {
it('includes a default submenu layout when submenu is empty', function() {
var item = new MenuItem({role: 'editMenu'})
assert.equal(item.label, 'Edit')
assert.equal(item.submenu.items[0].role, 'undo')
assert.equal(item.submenu.items[1].role, 'redo')
assert.equal(item.submenu.items[2].type, 'separator')
assert.equal(item.submenu.items[3].role, 'cut')
assert.equal(item.submenu.items[4].role, 'copy')
assert.equal(item.submenu.items[5].role, 'paste')
if (process.platform == 'darwin') {
assert.equal(item.submenu.items[6].role, 'pasteandmatchstyle')
assert.equal(item.submenu.items[7].role, 'delete')
assert.equal(item.submenu.items[8].role, 'selectall')
}
if (process.platform == 'win32') {
assert.equal(item.submenu.items[6].role, 'delete')
assert.equal(item.submenu.items[7].type, 'separator')
assert.equal(item.submenu.items[8].role, 'selectall')
}
})
it('overrides default layout when submenu is specified', function() {
var item = new MenuItem({role: 'editMenu', submenu: [{ role: 'close'}]})
assert.equal(item.label, 'Edit')
assert.equal(item.submenu.items[0].role, 'close')
})
})
describe('MenuItem windowMenu', function() {
it('includes a default submenu layout when submenu is empty', function() {
var item = new MenuItem({role: 'windowMenu'})
assert.equal(item.label, 'Window')
assert.equal(item.submenu.items[0].role, 'minimize')
assert.equal(item.submenu.items[1].role, 'close')
if (process.platform == 'darwin') {
assert.equal(item.submenu.items[2].type, 'separator')
assert.equal(item.submenu.items[3].role, 'front')
}
})
it('overrides default layout when submenu is specified', function() {
var item = new MenuItem({role: 'windowMenu', submenu: [{ role: 'copy'}]})
assert.equal(item.label, 'Window')
assert.equal(item.submenu.items[0].role, 'copy')
})
})
describe('MenuItem with custom properties in constructor', function () {
it('preserves the custom properties', function () {
var template = [{