This commit is contained in:
Cheng Zhao 2014-05-26 13:01:26 +08:00
Родитель 15d9b320db
Коммит 9b8edeb609
2 изменённых файлов: 11 добавлений и 3 удалений

Просмотреть файл

@ -68,6 +68,7 @@ Menu::insert = (pos, item) ->
@groupsMap[item.groupId].push item
# Setting a radio menu item should flip other items in the group.
v8Util.setHiddenValue item, 'checked', item.checked
Object.defineProperty item, 'checked',
enumerable: true
get: -> v8Util.getHiddenValue item, 'checked'

Просмотреть файл

@ -36,13 +36,20 @@ describe 'menu module', ->
]
menu.delegate.executeCommand menu.items[0].commandId
describe 'radio MenuItem', ->
it 'clicking an item should flip the checked property', ->
menu = Menu.buildFromTemplate [ label: 'text', type: 'radio' ]
describe 'MenuItem with checked property', ->
it 'clicking an checkbox item should flip the checked property', ->
menu = Menu.buildFromTemplate [ label: 'text', type: 'checkbox' ]
assert.equal menu.items[0].checked, false
menu.delegate.executeCommand menu.items[0].commandId
assert.equal menu.items[0].checked, true
it 'clicking an radio item should always make checked property true', ->
menu = Menu.buildFromTemplate [ label: 'text', type: 'radio' ]
menu.delegate.executeCommand menu.items[0].commandId
assert.equal menu.items[0].checked, true
menu.delegate.executeCommand menu.items[0].commandId
assert.equal menu.items[0].checked, true
it 'at least have one item checked in each group', ->
template = []
template.push label: "#{i}", type: 'radio' for i in [0..10]