Skip to content
Permalink
Browse files

Selectmenu tests: check item focus

  • Loading branch information
fnagel committed Aug 2, 2013
1 parent 34e10c1 commit a156c2cadc81acf0856feb95ad41fe5f1a38315e
Showing with 37 additions and 0 deletions.
  1. +37 −0 tests/unit/selectmenu/selectmenu_core.js
@@ -183,6 +183,43 @@ $.each([
start();
}, 1 );
});

asyncTest( "item focus - " + settings.type, function () {
expect( 4 );

var element = $( settings.selector ).selectmenu(),
button = element.selectmenu( "widget" ),
menu = element.selectmenu( "menuWidget" ),
links, activeItem, focusedItem;

// init menu
button.simulate( "focus" );

setTimeout(function() {
links = menu.find( "li.ui-menu-item a" );

button.trigger( "click" );
focusedItem = menu.find( "li.ui-menu-item a.ui-state-focus" );
equal( focusedItem.length, 1, "only one item has focus after first opening" );
equal( focusedItem.attr( "id" ), links.eq( element[ 0 ].selectedIndex ).attr( "id" ), "active item has focus after first opening" );

links.eq( 3 ).simulate( "mouseover" ).trigger( "click" );

button.trigger( "click" );
links.eq( 2 ).simulate( "mouseover" );
$( document ).trigger( "click" );

button.trigger( "click" );
links.eq( 1 ).simulate( "mouseover" );
$( document ).trigger( "click" );

button.trigger( "click" );
focusedItem = menu.find( "li.ui-menu-item a.ui-state-focus" );
equal( focusedItem.length, 1, "only one item has focus" );
equal( focusedItem.attr( "id" ), links.eq( element[ 0 ].selectedIndex ).attr( "id" ), "active item has focus" );
start();
}, 1 );
});
});

})( jQuery );

0 comments on commit a156c2c

Please sign in to comment.
You can’t perform that action at this time.