aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/selectmenu
diff options
context:
space:
mode:
authorScott González <scott.gonzalez@gmail.com>2014-04-22 12:19:12 -0400
committerScott González <scott.gonzalez@gmail.com>2014-04-22 12:19:12 -0400
commit56f6f92314f0846d874d2f7b4d3cebf6b73a343c (patch)
tree7e46429b1585384dc4c0b4c1ce9558e2f4769591 /tests/unit/selectmenu
parentd8062dc4cf7d2c08fe43334f50483e711c861f72 (diff)
downloadjquery-ui-56f6f92314f0846d874d2f7b4d3cebf6b73a343c.tar.gz
jquery-ui-56f6f92314f0846d874d2f7b4d3cebf6b73a343c.zip
Selectmenu: Test cleanup
Diffstat (limited to 'tests/unit/selectmenu')
-rw-r--r--tests/unit/selectmenu/selectmenu_events.js92
1 files changed, 47 insertions, 45 deletions
diff --git a/tests/unit/selectmenu/selectmenu_events.js b/tests/unit/selectmenu/selectmenu_events.js
index 2c10b4c87..2f3548d10 100644
--- a/tests/unit/selectmenu/selectmenu_events.js
+++ b/tests/unit/selectmenu/selectmenu_events.js
@@ -1,29 +1,29 @@
(function ( $ ) {
module( "selectmenu: events", {
- setup: function () {
+ setup: function() {
this.element = $( "#speed" );
}
});
-asyncTest( "change", function () {
- expect( 5 );
+asyncTest( "change", function() {
+ expect( 3 );
- var optionIndex = 1,
- button, menu, options;
+ var button, menu, options,
+ optionIndex = 1;
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.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" );
- equal( ui.item.value, options.eq( optionIndex ).text(), "ui.item.value property updated correctly" );
+ equal( ui.item.element[ 0 ], options.eq( optionIndex )[ 0 ],
+ "ui.item.element contains original option element" );
+ equal( ui.item.value, options.eq( optionIndex ).text(),
+ "ui.item.value property updated correctly" );
}
});
button = this.element.selectmenu( "widget" );
- menu = this.element.selectmenu( "menuWidget" ).parent();
+ menu = this.element.selectmenu( "menuWidget" );
options = this.element.find( "option" );
button.simulate( "focus" );
@@ -32,41 +32,46 @@ asyncTest( "change", function () {
button.trigger( "click" );
menu.find( "li" ).eq( optionIndex ).simulate( "mouseover" ).trigger( "click" );
start();
- }, 1 );
+ });
});
-test( "close", function () {
- expect( 4 );
+test( "close", function() {
+ expect( 2 );
+
+ var shouldFire;
this.element.selectmenu({
- close: function ( event ) {
- ok( event, "close event fired on close" );
- equal( event.type, "selectmenuclose", "event type set to selectmenuclose" );
+ close: function() {
+ ok( shouldFire, "close event fired on close" );
}
});
- this.element.selectmenu( "open" ).selectmenu( "close" );
-
+ shouldFire = false;
+ this.element.selectmenu( "open" )
+ shouldFire = true;
+ this.element.selectmenu( "close" );
+ shouldFire = false;
this.element.selectmenu( "open" );
+ shouldFire = true;
$( "body" ).trigger( "mousedown" );
});
-asyncTest( "focus", function () {
- expect( 12 );
+asyncTest( "focus", function() {
+ expect( 9 );
- var that = this,
+ var button, menu, links,
+ that = this,
optionIndex = this.element[ 0 ].selectedIndex + 1,
- options = this.element.find( "option" ),
- button, menu, links;
+ options = this.element.find( "option" );
this.element.selectmenu({
- focus: function ( event, ui ) {
- ok( event, "focus event fired on element #" + optionIndex + " mouseover" );
- equal( event.type, "selectmenufocus", "event type set to selectmenufocus" );
+ focus: function( event, ui ) {
+ ok( true, "focus event fired on element #" + optionIndex + " mouseover" );
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" );
+ equal( ui.item.element[ 0 ], options.eq( optionIndex )[ 0 ],
+ "ui.item.element contains original option element" );
}
});
@@ -74,7 +79,6 @@ asyncTest( "focus", function () {
menu = this.element.selectmenu( "menuWidget" );
button.simulate( "focus" );
-
setTimeout(function() {
button.simulate( "keydown", { keyCode: $.ui.keyCode.DOWN } );
@@ -85,20 +89,19 @@ asyncTest( "focus", function () {
optionIndex += 1;
links.eq( optionIndex ).simulate( "mouseover" );
- // this tests for unwanted, additional focus event on close
+ // This tests for unwanted, additional focus event on close
that.element.selectmenu( "close" );
start();
- }, 1 );
+ });
});
-test( "open", function () {
- expect( 2 );
+test( "open", function() {
+ expect( 1 );
this.element.selectmenu({
- open: function ( event ) {
- ok( event, "open event fired on open" );
- equal( event.type, "selectmenuopen", "event type set to selectmenuopen" );
+ open: function() {
+ ok( true, "open event fired on open" );
}
});
@@ -106,30 +109,29 @@ test( "open", function () {
});
-asyncTest( "select", function () {
- expect( 4 );
+asyncTest( "select", function() {
+ expect( 3 );
this.element.selectmenu({
- select: function ( event, ui ) {
- ok( event, "select event fired on item select" );
- equal( event.type, "selectmenuselect", "event type set to selectmenuselect" );
+ select: function( event, ui ) {
+ ok( true, "select event fired on item select" );
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" );
+ equal( ui.item.element[ 0 ], options.eq( optionIndex )[ 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" ),
options = this.element.find( "option" ),
optionIndex = 1;
button.simulate( "focus" );
-
setTimeout(function() {
button.trigger( "click" );
menu.find( "li" ).eq( optionIndex ).simulate( "mouseover" ).trigger( "click" );
start();
- }, 1 );
+ });
});
-})(jQuery);
+})( jQuery );