2011-01-16 07:15:17 +00:00
|
|
|
/*
|
|
|
|
|
* mobile select unit tests
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
(function($){
|
2011-03-29 16:32:10 +00:00
|
|
|
var libName = "jquery.mobile.forms.select.js";
|
2011-01-16 07:15:17 +00:00
|
|
|
|
2011-03-26 04:37:45 +00:00
|
|
|
$(document).bind('mobileinit', function(){
|
|
|
|
|
$.mobile.selectmenu.prototype.options.nativeMenu = false;
|
|
|
|
|
});
|
|
|
|
|
|
2011-03-13 06:55:48 +00:00
|
|
|
module(libName, {
|
|
|
|
|
teardown: function(){ location.hash = ""; }
|
|
|
|
|
});
|
2011-01-16 07:15:17 +00:00
|
|
|
|
|
|
|
|
test( "a large select menu should come up in a dialog many times", function(){
|
|
|
|
|
var menu, select = $("#select-choice-many-container a");
|
|
|
|
|
|
|
|
|
|
// bring up the dialog
|
2011-03-29 16:32:10 +00:00
|
|
|
select.trigger("click");
|
2011-01-16 07:15:17 +00:00
|
|
|
menu = $("#select-choice-many-menu");
|
|
|
|
|
same(menu.parents('.ui-dialog').length, 1);
|
|
|
|
|
|
|
|
|
|
// select and close the dialog
|
2011-01-28 06:44:23 +00:00
|
|
|
menu.parents('ui-dialog').find("span.ui-icon-delete").click();
|
2011-01-16 07:15:17 +00:00
|
|
|
|
|
|
|
|
//bring up the dialog again
|
2011-03-29 16:32:10 +00:00
|
|
|
select.trigger("click");
|
2011-01-16 07:15:17 +00:00
|
|
|
same(menu.parents('.ui-dialog').length, 1);
|
|
|
|
|
});
|
2011-01-27 05:20:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
test( "firing a click at least 400 ms later on the select screen overlay does close it", function(){
|
|
|
|
|
$.Event.prototype.originalEvent = {
|
|
|
|
|
touches: [ 'foo' ]
|
|
|
|
|
};
|
|
|
|
|
|
2011-03-29 16:32:10 +00:00
|
|
|
$("#select-choice-few-button").trigger("click");
|
2011-01-27 05:20:40 +00:00
|
|
|
|
|
|
|
|
// click the first menu item
|
|
|
|
|
setTimeout(function(){
|
|
|
|
|
$("#select-choice-few-menu a:first").click();
|
|
|
|
|
}, 400);
|
|
|
|
|
|
|
|
|
|
// verify the menu is hidden
|
|
|
|
|
setTimeout(function(){
|
|
|
|
|
same($("#select-choice-few-menu").parent(".ui-selectmenu-hidden").length, 1);
|
|
|
|
|
start();
|
|
|
|
|
}, 500);
|
|
|
|
|
|
|
|
|
|
stop();
|
|
|
|
|
});
|
2011-03-13 06:52:44 +00:00
|
|
|
|
2011-02-02 05:57:34 +00:00
|
|
|
test( "selects marked with data-native-menu=true should use a div as their button", function(){
|
|
|
|
|
same($("#select-choice-native-container div.ui-btn").length, 1);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test( "selects marked with data-native-menu=true should not have a custom menu", function(){
|
|
|
|
|
same($("#select-choice-native-container ul").length, 0);
|
|
|
|
|
});
|
2011-03-13 06:52:44 +00:00
|
|
|
|
2011-02-02 05:59:54 +00:00
|
|
|
test( "selects marked with data-native-menu=true should sit inside the button", function(){
|
|
|
|
|
same($("#select-choice-native-container div.ui-btn select").length, 1);
|
|
|
|
|
});
|
2011-03-29 16:32:10 +00:00
|
|
|
})(jQuery);
|