}
});
-test( "change", function () {
+asyncTest( "change", function () {
expect( 5 );
var that = this,
- optionIndex = 1;
+ optionIndex = 1,
+ button, menu, options;
this.element.selectmenu({
change: function ( event, ui ) {
}
});
- var button = this.element.selectmenu( "widget" ),
- menu = this.element.selectmenu( "menuWidget" ).parent(),
- options = this.element.find( "option" );
+ button = this.element.selectmenu( "widget" );
+ menu = this.element.selectmenu( "menuWidget" ).parent();
+ options = this.element.find( "option" );
- button.simulate( "focus" ).simulate( "click" );
- menu.find( "a" ).eq( optionIndex ).simulate( "mouseover" ).simulate( "click" );
+ button.simulate( "focus" );
+
+ setTimeout(function() {
+ button.simulate( "click" );
+ menu.find( "a" ).eq( optionIndex ).simulate( "mouseover" ).simulate( "click" );
+ start();
+ }, 1 );
});
equal( event.type, "selectmenuclose", "event type set to selectmenuclose" );
}
});
-
+
this.element.selectmenu( "open" ).selectmenu( "close" );
-
+
this.element.selectmenu( "open" );
$( "body" ).simulate( "click" );
});
-test( "focus", function () {
+asyncTest( "focus", function () {
expect( 12 );
- var button, menu, links,
+ var that = this,
optionIndex = this.element[ 0 ].selectedIndex + 1,
- options = this.element.find( "option" );
+ options = this.element.find( "option" ),
+ button, menu, links;
this.element.selectmenu({
focus: function ( event, ui ) {
button = this.element.selectmenu( "widget" ),
menu = this.element.selectmenu( "menuWidget" );
- button
- .simulate( "focus" )
- .simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
+ button.simulate( "focus" )
- 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" );
+ setTimeout(function() {
+ button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
- // this tests for unwanted, additional focus event on close
- this.element.selectmenu( "close" );
+ 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" );
+
+ // this tests for unwanted, additional focus event on close
+ that.element.selectmenu( "close" );
+ start();
+ }, 1 );
});
});
-test( "select", function () {
+asyncTest( "select", function () {
expect( 4 );
this.element.selectmenu({
options = this.element.find( "option" ),
optionIndex = 1;
- button.simulate( "focus" ).simulate( "click" );
- menu.find( "a" ).eq( optionIndex ).simulate( "mouseover" ).simulate( "click" );
+ button.simulate( "focus" );
+
+ setTimeout(function() {
+ button.simulate( "click" );
+ menu.find( "a" ).eq( optionIndex ).simulate( "mouseover" ).simulate( "click" );
+ start();
+ }, 1 );
});
})(jQuery);
equal( element.find( "option" ).first().text(), menu.find( "li" ).not( ".ui-selectmenu-optgroup" ).first().text(), "changed item" );
});
-test( "refresh - change selected option", function () {
+asyncTest( "refresh - change selected option", function () {
expect( 3 );
var element = $( "#speed" ).selectmenu(),
button.simulate( "focus" );
- equal( element.find( "option:selected" ).text(), button.text(), "button text after focus" );
+ setTimeout(function() {
+ equal( element.find( "option:selected" ).text(), button.text(), "button text after focus" );
- element.find( "option" ).eq( 2 ).removeAttr( "selected" );
- element.find( "option" ).eq( 0 ).attr( "selected", "selected" );
- element.selectmenu( "refresh" );
+ element[ 0 ].selectedIndex = 0
+ element.selectmenu( "refresh" );
+
+ equal( element.find( "option:selected" ).text(), button.text(), "button text after changing selected option" );
- equal( element.find( "option:selected" ).text(), button.text(), "button text after changing selected option" );
+ start();
+ }, 1 );
});