Skip to content
Permalink
Browse files

Selectmenu Tests: improve events tests, check for original option ele…

…ment not only for node type
  • Loading branch information
fnagel committed May 12, 2013
1 parent 1c878ce commit 97cca1ed78e902b8580fb88da37122bf20893d89
Showing with 11 additions and 7 deletions.
  1. +11 −7 tests/unit/selectmenu/selectmenu_events.js
@@ -8,19 +8,21 @@ module( "selectmenu: events", {

test( "change", function () {
expect( 4 );

var that = this;

this.element.selectmenu({
change: function ( event, ui ) {
ok( event, "change event fired on change" );
equal( event.type, "selectmenuchange", "event type set to selectmenuchange" );
equal( ui.item.element[ 0 ].nodeName.toLowerCase(), "option", "ui.item.element[ 0 ] points to original option element" );
equal( ui.item.value, value, "ui.item.value property updated correctly" );
equal( ui.item.element[ 0 ], options.eq( ui.item.index )[ 0 ], "ui.item.element contains original option element" );
equal( ui.item.value, options.eq( ui.item.index ).text(), "ui.item.value property updated correctly" );
}
});

var button = this.element.selectmenu( "widget" ),
menu = this.element.selectmenu( "menuWidget" ).parent(),
value = this.element.find( "option" ).first().text();
options = this.element.find( "option" );

button.simulate( "focus" ).simulate( "click" );
menu.find( "a" ).first().simulate( "mouseover" ).simulate( "click" );
@@ -44,13 +46,14 @@ test( "close", function () {
test( "focus", function () {
expect( 3 );

var button, menu, links;
var button, menu, links,
options = this.element.find( "option" );

this.element.selectmenu({
focus: function ( event, ui ) {
ok( event, "focus event fired on mouseover" );
equal( event.type, "selectmenufocus", "event type set to selectmenufocus" );
equal( ui.item.element[ 0 ].nodeName.toLowerCase(), "option", "ui points to original option element" );
equal( ui.item.element[ 0 ], options.eq( ui.item.index )[ 0 ], "ui.item.element contains original option element" );
}
});

@@ -89,12 +92,13 @@ test( "select", function () {
select: function ( event, ui ) {
ok( event, "select event fired on item select" );
equal( event.type, "selectmenuselect", "event type set to selectmenuselect" );
equal( ui.item.element[ 0 ].nodeName.toLowerCase(), "option", "ui points to original option element" );
equal( ui.item.element[ 0 ], options.eq( ui.item.index )[ 0 ], "ui.item.element contains original option element" );
}
});

var button = this.element.selectmenu( "widget" ),
menu = this.element.selectmenu( "menuWidget" ).parent();
menu = this.element.selectmenu( "menuWidget" ).parent(),
options = this.element.find( "option" );

button.simulate( "focus" ).simulate( "click" );
menu.find( "a" ).first().simulate( "mouseover" ).simulate( "click" );

0 comments on commit 97cca1e

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