diff --git a/tests/jquery.testHelper.js b/tests/jquery.testHelper.js index ed4241b8..f69a0afb 100644 --- a/tests/jquery.testHelper.js +++ b/tests/jquery.testHelper.js @@ -103,6 +103,19 @@ // invoke the function which should, in some fashion, // trigger the defined event fn(timedOut); + }, + + decorate: function(opts){ + var thisVal = opts.this || window; + + return function(){ + var returnVal; + opts.before && opts.before.apply(thisVal, arguments); + returnVal = opts.fn.apply(thisVal, arguments); + opts.after && opts.after.apply(thisVal, arguments); + + return returnVal; + }; } }; })(jQuery); \ No newline at end of file diff --git a/tests/unit/select/index.html b/tests/unit/select/index.html index 9581166b..a286ec73 100644 --- a/tests/unit/select/index.html +++ b/tests/unit/select/index.html @@ -9,9 +9,9 @@ + - @@ -27,7 +27,7 @@
- @@ -45,17 +45,17 @@
-
- +
- @@ -111,7 +111,7 @@
- @@ -167,7 +167,7 @@
- @@ -223,7 +223,7 @@
- @@ -288,7 +288,7 @@ } - @@ -297,7 +297,7 @@
- diff --git a/tests/unit/select/select_core.js b/tests/unit/select/select_core.js index f489db8f..83e8b33e 100644 --- a/tests/unit/select/select_core.js +++ b/tests/unit/select/select_core.js @@ -3,46 +3,59 @@ */ (function($){ - var libName = "jquery.mobile.forms.select.js"; - - $(document).bind("mobileinit", function(){ - $.mobile.selectmenu.prototype.options.nativeMenu = false; - }); + var libName = "jquery.mobile.forms.select.js", + originalDefaultDialogTrans = $.mobile.defaultDialogTransition, + originalDefTransitionHandler = $.mobile.defaultTransitionHandler; module(libName, { - teardown: function(){ location.hash = ""; } + teardown: function(){ + location.hash = ""; + $.mobile.defaultDialogTransition = originalDefaultDialogTrans; + $.mobile.defaultTransitionHandler = originalDefTransitionHandler; + } }); - + asyncTest( "a large select menu should use the default dialog transition", function(){ - var select = $("#select-choice-many-container-1 a"), - prevDefault = $.mobile.defaultDialogTransition; - - //set to something else - $.mobile.defaultDialogTransition = "fooz"; - - $.testHelper.sequence([ + var select = $("#select-choice-many-container-1 a"); + + //set to something else + + $.mobile.defaultTransitionHandler = $.testHelper.decorate({ + fn: $.mobile.defaultTransitionHandler, + + before: function(name){ + same(name, $.mobile.defaultDialogTransition); + } + }); + + setTimeout(function(){ + $.testHelper.pageSequence([ function(){ // bring up the dialog select.trigger("click"); - ok( $("#select-choice-many-1-menu").closest(".ui-page").hasClass( $.mobile.defaultDialogTransition ) ); - $("#select-choice-many-1").selectmenu("close"); }, - + + function(){ + $.mobile.activePage.find(".ui-header .ui-btn").click(); + }, + function(){ start(); } - ], 500); + ]); + }, 1000); }); asyncTest( "a large select menu should come up in a dialog many times", function(){ var menu, select = $("#select-choice-many-container a"); - $.testHelper.sequence([ + $.testHelper.pageSequence([ function(){ // bring up the dialog select.trigger("click"); }, + function(){ menu = $("#select-choice-many-menu"); same(menu.closest('.ui-dialog').length, 1); @@ -50,7 +63,7 @@ function(){ // select and close the dialog - $("#select-choice-many-menu").selectmenu("close"); + $.mobile.activePage.find(".ui-header .ui-btn").click(); }, function(){ @@ -59,25 +72,29 @@ }, function(){ - same(menu.closest('.ui-dialog').length, 1); - $("#select-choice-many-menu").selectmenu("close"); + $.mobile.activePage.find(".ui-header .ui-btn").click(); }, + function(){ start(); } - ], 500); + ]); }); asyncTest( "custom select menu always renders screen from the left", function(){ expect( 1 ); var select = $("ul#select-offscreen-menu"); - $("#select-offscreen-container a").trigger("click"); + $.testHelper.sequence([ + function(){ + $("#select-offscreen-container a").trigger("click"); + }, - setTimeout(function(){ - ok(select.offset().left >= 30); - start(); - }, 1000); + function(){ + ok(select.offset().left >= 30); + start(); + } + ], 1000); }); asyncTest( "selecting an item from a dialog sized custom select menu leaves no dialog hash key", function(){ @@ -85,12 +102,12 @@ $.testHelper.pageSequence([ function(){ - $("#select-choice-many-container-hash-check a").trigger("click"); + $("#select-choice-many-container-hash-check a").click(); }, function(){ ok(location.hash.indexOf(dialogHashKey) > -1); - $(".ui-page-active li:first a").trigger("click"); + $.mobile.activePage.find(".ui-header .ui-btn").click(); }, function(){ @@ -100,17 +117,17 @@ ]); }); - asyncTest( "dialog sized select menu opened many times remains a dialog", function(){ + asyncTest( "dialog sized select menu opened many times remains a dialog", function(){ var dialogHashKey = "ui-state=dialog", openDialogSequence = [ function(){ - $("#select-choice-many-container-many-clicks a").trigger("vclick"); + $("#select-choice-many-container-many-clicks a").click(); }, function(){ ok(location.hash.indexOf(dialogHashKey) > -1, "hash should have the dialog hash key"); - $(".ui-page-active li").trigger("click"); + $(".ui-page-active li").click(); } ], @@ -141,7 +158,7 @@ function() { menu = $(".ui-selectmenu-list"); - equal(menu.width(), menu.find("li:nth-child(2) .ui-btn-text").width(), "ui-btn-text element should not overflow") + equal(menu.width(), menu.find("li:nth-child(2) .ui-btn-text").width(), "ui-btn-text element should not overflow"); start(); } ], 500);