fixed select tests to click the button instead of calling the select menu method

This commit is contained in:
John Bender 2011-07-15 15:22:47 -07:00
parent 2e2f318562
commit 53a8023b14
3 changed files with 74 additions and 44 deletions

View file

@ -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);

View file

@ -9,9 +9,9 @@
<script src="../jquery.setNameSpace.js"></script>
<script src="../../../external/qunit.js"></script>
<script src="../../../tests/jquery.testHelper.js"></script>
<script src="../../../js"></script>
<script src="select_events.js"></script>
<script src="select_core.js"></script>
<script src="../../../js"></script>
<link rel="stylesheet" href="../../../themes/default/"/>
@ -27,7 +27,7 @@
<div id="foo" data-nstest-role="page">
<div data-nstest-role="fieldcontain" id="select-choice-few-container">
<select name="select-choice-few" id="select-choice-few">
<select name="select-choice-few" id="select-choice-few" data-nstest-native-menu="false">
<option value="standard">Standard: 7 day</option>
<option value="rush">Rush: 3 days</option>
<option value="express">Express: next day</option>
@ -45,17 +45,17 @@
</div>
<div data-nstest-role="fieldcontain" id="select-choice-global-native-container">
<select name="select-choice-global-native" id="select-choice-global-native">
<select name="select-choice-global-native" id="select-choice-global-native" data-nstest-native-menu="false">
<option value="standard">Standard: 7 day</option>
<option value="rush">Rush: 3 days</option>
<option value="express">Express: next day</option>
<option value="overnight">Overnight</option>
</select>
</div>
<div data-nstest-role="fieldcontain" id="select-choice-many-container-1">
<label for="select-choice-many-1" class="select">Your state:</label>
<select name="select-choice-many-1" id="select-choice-many-1">
<select name="select-choice-many-1" id="select-choice-many-1" data-nstest-native-menu="false">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
@ -111,7 +111,7 @@
<div data-nstest-role="fieldcontain" id="select-choice-many-container">
<label for="select-choice-many" class="select">Your state:</label>
<select name="select-choice-many" id="select-choice-many">
<select name="select-choice-many" id="select-choice-many" data-nstest-native-menu="false">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
@ -167,7 +167,7 @@
<div data-nstest-role="fieldcontain" id="select-choice-many-container-hash-check">
<label for="select-choice-many-hash-check" class="select">Your state:</label>
<select name="select-choice-many-hash-check" id="select-choice-many-hash-check">
<select name="select-choice-many-hash-check" id="select-choice-many-hash-check" data-nstest-native-menu="false">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
@ -223,7 +223,7 @@
<div data-nstest-role="fieldcontain" id="select-choice-many-container-many-clicks">
<label for="select-choice-many-many-clicks" class="select">Your state:</label>
<select name="select-choice-many-many-clicks" id="select-choice-many-many-clicks">
<select name="select-choice-many-many-clicks" id="select-choice-many-many-clicks" data-nstest-native-menu="false">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
@ -288,7 +288,7 @@
}
</style>
<select name="select-choice-few" id="select-offscreen">
<select name="select-choice-few" id="select-offscreen" data-nstest-native-menu="false">
<option value="standard">Standard: 7 day</option>
<option value="rush">Rush: 3 days</option>
<option value="express">Express: next day</option>
@ -297,7 +297,7 @@
</div>
<div data-nstest-role="fieldcontain" id="select-long-option-label-container">
<select name="select-long-option-label" id="select-long-option-label">
<select name="select-long-option-label" id="select-long-option-label" data-nstest-native-menu="false">
<option value="short">Choice 1</option>
<option value="long">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</option>
</select>

View file

@ -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);