aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit
diff options
context:
space:
mode:
authorkborchers <kris.borchers@gmail.com>2012-04-18 21:29:39 -0500
committerkborchers <kris.borchers@gmail.com>2012-04-18 21:29:39 -0500
commit890a45a22c7b7a8ae5e7ff64cfd44008bb2cdb88 (patch)
treecace0e9c533307fa66498832eb8992a001d1c2ed /tests/unit
parent1ce42f4328167826e9868ee1bf21f96317927dec (diff)
downloadjquery-ui-890a45a22c7b7a8ae5e7ff64cfd44008bb2cdb88.tar.gz
jquery-ui-890a45a22c7b7a8ae5e7ff64cfd44008bb2cdb88.zip
Menu: Add unit tests for testing disabled items
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/menu/menu.html16
-rw-r--r--tests/unit/menu/menu_events.js52
2 files changed, 68 insertions, 0 deletions
diff --git a/tests/unit/menu/menu.html b/tests/unit/menu/menu.html
index 76f4a7a31..9a598ec8d 100644
--- a/tests/unit/menu/menu.html
+++ b/tests/unit/menu/menu.html
@@ -251,6 +251,22 @@
</blockquote>
</div>
+<ul id="menu6">
+ <li class="foo"><a class="foo" href="#">Aberdeen</a></li>
+ <li class="foo ui-state-disabled"><a class="foo" href="#">Ada</a></li>
+ <li class="foo"><a class="foo" href="#">Adamsville</a></li>
+ <li class="foo"><a class="foo" href="#">Addyston</a></li>
+ <li class="ui-state-disabled">
+ <a href="#">Delphi</a>
+ <ul>
+ <li class="foo"><a class="foo" href="#">Ada</a></li>
+ <li class="foo"><a class="foo" href="#">Saarland</a></li>
+ <li class="foo"><a class="foo" href="#">Salzburg</a></li>
+ </ul>
+ </li>
+ <li class="foo"><a class="foo" href="#">Saarland</a></li>
+</ul>
+
<div id="log"></div>
</div>
diff --git a/tests/unit/menu/menu_events.js b/tests/unit/menu/menu_events.js
index bee6fcfa6..7d127c431 100644
--- a/tests/unit/menu/menu_events.js
+++ b/tests/unit/menu/menu_events.js
@@ -466,4 +466,56 @@ asyncTest("handle keyboard navigation on menu with scroll and with submenus", fu
}
});
+asyncTest("handle keyboard navigation and mouse click on menu with disabled items", function() {
+ expect(6);
+ var element = $('#menu6').menu({
+ select: function(event, ui) {
+ menu_log($(ui.item[0]).text());
+ },
+ focus: function( event, ui ) {
+ menu_log($(event.target).find(".ui-state-focus").parent().index());
+ }
+ });
+
+ menu_log("keydown",true);
+ element.one( "menufocus", function( event, ui ) {
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+ equal( $("#log").html(), "1,keydown,", "Keydown focus but not select disabled item");
+ setTimeout( menukeyboard1, 50 );
+ });
+ element.focus();
+
+
+ function menukeyboard1() {
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ equal( $("#log").html(), "4,3,2,keydown,", "Keydown focus disabled item with submenu");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.LEFT } );
+ equal( $("#log").html(), "keydown,", "Keydown LEFT (no effect)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.RIGHT } );
+
+ setTimeout( function() {
+ equal( $("#log").html(), "keydown,", "Keydown RIGHT (no effect on disabled sub-menu)");
+
+ menu_log("keydown",true);
+ element.simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } );
+
+ setTimeout( function() {
+ equal( $("#log").html(), "keydown,", "Keydown ENTER (no effect on disabled sub-menu)");
+ menu_log("click",true);
+ menu_click( element, "1" );
+ equal( $("#log").html(), "click,", "Click disabled item (no effect)");
+ start();
+ }, 50);
+ }, 50);
+ }
+});
+
})(jQuery);