aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/selectmenu
diff options
context:
space:
mode:
authorFelix Nagel <info@felixnagel.com>2013-05-30 21:02:38 +0200
committerFelix Nagel <info@felixnagel.com>2013-05-30 21:02:38 +0200
commit29f726c55351ea78d01a04d25986b15da7b56d63 (patch)
tree3a301ee77f5026ed5c840895ff38c682d0eefa9f /tests/unit/selectmenu
parentcccb8c6e826b8140dd99f225a28cc6f725e86ced (diff)
downloadjquery-ui-29f726c55351ea78d01a04d25986b15da7b56d63.tar.gz
jquery-ui-29f726c55351ea78d01a04d25986b15da7b56d63.zip
Selectmenu tests: improve focus callback event test, add keydown focus test, add multiple focus events test
Diffstat (limited to 'tests/unit/selectmenu')
-rw-r--r--tests/unit/selectmenu/selectmenu_events.js23
1 files changed, 15 insertions, 8 deletions
diff --git a/tests/unit/selectmenu/selectmenu_events.js b/tests/unit/selectmenu/selectmenu_events.js
index 99d5b591c..49f0c598c 100644
--- a/tests/unit/selectmenu/selectmenu_events.js
+++ b/tests/unit/selectmenu/selectmenu_events.js
@@ -44,29 +44,36 @@ test( "close", function () {
test( "focus", function () {
- expect( 3 );
+ expect( 12 );
var button, menu, links,
+ optionIndex = this.element[ 0 ].selectedIndex + 1,
options = this.element.find( "option" );
this.element.selectmenu({
focus: function ( event, ui ) {
- ok( event, "focus event fired on mouseover" );
+ ok( event, "focus event fired on element #" + optionIndex + " mouseover" );
equal( event.type, "selectmenufocus", "event type set to selectmenufocus" );
- equal( ui.item.element[ 0 ], options.eq( ui.item.index )[ 0 ], "ui.item.element contains original option element" );
+ equal( ui.item.index, optionIndex, "ui.item.index contains correct option index" );
+ equal( ui.item.element[ 0 ], options.eq( optionIndex )[ 0 ], "ui.item.element contains original option element" );
}
});
button = this.element.selectmenu( "widget" ),
menu = this.element.selectmenu( "menuWidget" );
- button.simulate( "focus" );
- links = menu.find( "li.ui-menu-item a" );
-
+ button
+ .simulate( "focus" )
+ .simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+
button.simulate( "click" );
+ links = menu.find( "li.ui-menu-item a" );
+ optionIndex = 0;
+ links.eq( optionIndex ).simulate( "mouseover" );
+ optionIndex += 1;
+ links.eq( optionIndex ).simulate( "mouseover" );
- menu.find( "a" ).last().simulate( "mouseover" );
-
+ // this tests for unwanted, additional focus event on close
this.element.selectmenu( "close" );
});