From 3483b9460bb8da116ad0d4aa19ee6f33b4134faa Mon Sep 17 00:00:00 2001 From: Felix Nagel Date: Mon, 1 Jul 2013 22:59:43 +0200 Subject: [PATCH] Selectmenu Tests: add item looping tests --- tests/unit/selectmenu/selectmenu_core.js | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/unit/selectmenu/selectmenu_core.js b/tests/unit/selectmenu/selectmenu_core.js index e6cbcbeed..5804b6f00 100644 --- a/tests/unit/selectmenu/selectmenu_core.js +++ b/tests/unit/selectmenu/selectmenu_core.js @@ -156,6 +156,34 @@ $.each([ }, 1 ); }, 1 ); }); + + asyncTest( "item looping - " + settings.type, function () { + expect( 2 ); + + var links, + element = $( settings.selector ).selectmenu(), + button = element.selectmenu( "widget" ), + menu = element.selectmenu( "menuWidget" ), + options = element.find( "option" ); + + // init menu + button.simulate( "focus" ); + + setTimeout(function() { + links = menu.find( "li.ui-menu-item a" ); + + button.trigger( "click" ); + links.first().simulate( "mouseover" ).trigger( "click" ); + button.simulate( "keydown", { keyCode: $.ui.keyCode.UP } ); + equal( element[ 0 ].selectedIndex, 0, "No looping beyond first item" ); + + button.trigger( "click" ); + links.last().simulate( "mouseover" ).trigger( "click" ); + button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } ); + equal( element[ 0 ].selectedIndex + 1, links.length, "No looping behind last item" ); + start(); + }, 1 ); + }); }); })( jQuery ); -- 2.39.5