From 9b8edeb60999b9432bf4b5dc78b7d93c19727afb Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 26 May 2014 13:01:26 +0800 Subject: [PATCH] Fix specs. --- atom/browser/api/lib/menu.coffee | 1 + spec/api-menu-spec.coffee | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/atom/browser/api/lib/menu.coffee b/atom/browser/api/lib/menu.coffee index 03901443..442e5419 100644 --- a/atom/browser/api/lib/menu.coffee +++ b/atom/browser/api/lib/menu.coffee @@ -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' diff --git a/spec/api-menu-spec.coffee b/spec/api-menu-spec.coffee index 5ac7c14a..729795c2 100644 --- a/spec/api-menu-spec.coffee +++ b/spec/api-menu-spec.coffee @@ -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] -- 2.43.0