Skip to content

Commit

Permalink
Selectmenu Tests: add item looping tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fnagel committed Jul 1, 2013
1 parent ff1bb14 commit 3483b94
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/unit/selectmenu/selectmenu_core.js
Expand Up @@ -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 );

0 comments on commit 3483b94

Please sign in to comment.