electron/spec/api/menu.coffee

37 lines
1.1 KiB
CoffeeScript
Raw Normal View History

assert= require 'assert'
remote = require 'remote'
Menu = remote.require 'menu'
2013-08-14 04:09:53 +00:00
MenuItem = remote.require 'menu-item'
describe 'Menu API', ->
describe 'Menu.buildFromTemplate', ->
it 'should be able to attach extra fields', ->
menu = Menu.buildFromTemplate [label: 'text', extra: 'field']
assert.equal menu.items[0].extra, 'field'
2013-08-14 04:09:53 +00:00
describe 'Menu.insert', ->
it 'should store item in @items by its index', ->
menu = Menu.buildFromTemplate [
{label: '1'}
{label: '2'}
{label: '3'}
]
item = new MenuItem(label: 'inserted')
menu.insert 1, item
assert.equal menu.items[0].label, '1'
assert.equal menu.items[1].label, 'inserted'
assert.equal menu.items[2].label, '2'
assert.equal menu.items[3].label, '3'
2013-08-14 04:51:37 +00:00
describe 'MenuItem.click', ->
it 'should be called with the item object passed', (done) ->
menu = Menu.buildFromTemplate [
2013-08-14 04:51:37 +00:00
label: 'text'
click: (item) ->
assert.equal item.constructor.name, 'MenuItem'
assert.equal item.label, 'text'
done()
]
menu.delegate.executeCommand menu.items[0].commandId