Chromium Code Reviews| Index: remoting/webapp/unittests/menu_button_unittest.js |
| diff --git a/remoting/webapp/unittests/menu_button_unittest.js b/remoting/webapp/unittests/menu_button_unittest.js |
| index 9e687a4504656bd047d10a99bd1ecb8ae209de06..f09f4abf2e3302f351613c08093e9aad70ec946c 100644 |
| --- a/remoting/webapp/unittests/menu_button_unittest.js |
| +++ b/remoting/webapp/unittests/menu_button_unittest.js |
| @@ -7,7 +7,8 @@ |
| 'use strict'; |
| var menuButton = null; |
| -var menuShown = false; |
| +var onShow = sinon.spy(); |
| +var onHide = sinon.spy(); |
|
kelvinp
2014/07/23 18:49:08
To avoid side-effect.
We should
var onShow = null;
Jamie
2014/07/23 20:00:38
Good catch! Done.
|
| module('MenuButton', { |
| setup: function() { |
| @@ -21,8 +22,7 @@ module('MenuButton', { |
| '</span>'; |
| menuButton = new remoting.MenuButton( |
| document.getElementById('menu-button-container'), |
| - function() { menuShown = true; }); |
| - menuShown = false; |
| + onShow, onHide); |
| }, |
| teardown: function() { |
| } |
| @@ -57,10 +57,13 @@ test('should dismiss when menu item is clicked', function() { |
| ok(menu.offsetWidth == 0 && menu.offsetHeight == 0); |
| }); |
| -test('should invoke callback', function() { |
| - ok(!menuShown); |
| +test('should invoke callbacks', function() { |
| + ok(!onShow.called); |
| menuButton.button().click(); |
| - ok(menuShown); |
| + ok(onShow.called); |
| + ok(!onHide.called); |
| + document.body.click(); |
| + ok(onHide.called); |
| }); |
| test('select method should set/unset background image', function() { |