From: Felix Nagel Date: Thu, 30 May 2013 19:02:38 +0000 (+0200) Subject: Selectmenu tests: improve focus callback event test, add keydown focus test, add... X-Git-Tag: 1.11.0-beta.1~160^2~61 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=29f726c55351ea78d01a04d25986b15da7b56d63;p=jquery-ui.git Selectmenu tests: improve focus callback event test, add keydown focus test, add multiple focus events test --- 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" ); });