2011-10-13 20:21:47 +00:00
|
|
|
/*
|
|
|
|
|
* degradeInputs unit tests
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
(function($){
|
2011-12-09 20:51:38 +00:00
|
|
|
module('jquery.mobile.slider.js');
|
|
|
|
|
|
2011-10-13 22:50:29 +00:00
|
|
|
test('keepNative elements should not be degraded', function() {
|
2011-12-09 20:51:38 +00:00
|
|
|
same($('input#not-to-be-degraded').attr("type"), "range");
|
2011-10-13 22:50:29 +00:00
|
|
|
});
|
2011-12-09 20:51:38 +00:00
|
|
|
|
2011-12-09 20:52:53 +00:00
|
|
|
asyncTest('should degrade input type to a different type, as specified in page options', function(){
|
2011-12-09 20:51:38 +00:00
|
|
|
var degradeInputs = $.mobile.page.prototype.options.degradeInputs;
|
|
|
|
|
|
|
|
|
|
expect( degradeInputs.length );
|
|
|
|
|
|
2011-12-09 20:52:53 +00:00
|
|
|
// NOTE the initial page is already enhanced (or expected to be) so we load the dialog to enhance it
|
|
|
|
|
// and _expect_ that the default page will remain "unreaped". This will break if that assumption changes
|
|
|
|
|
$.testHelper.pageSequence([
|
|
|
|
|
function() {
|
|
|
|
|
$.mobile.changePage( "#dialog" );
|
|
|
|
|
},
|
2011-12-09 20:51:38 +00:00
|
|
|
|
2011-12-09 20:52:53 +00:00
|
|
|
function() {
|
|
|
|
|
$.each(degradeInputs, function( oldType, newType ) {
|
|
|
|
|
if (newType === false) {
|
|
|
|
|
newType = oldType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$('#page-test-container').html('<input type="' + oldType + '" />').trigger("create");
|
2011-12-09 20:51:38 +00:00
|
|
|
|
2011-12-09 20:52:53 +00:00
|
|
|
same($('#page-test-container input').attr("type"), newType, "type attr on page is: " + newType);
|
2011-12-09 20:51:38 +00:00
|
|
|
|
2011-12-09 20:52:53 +00:00
|
|
|
$('#dialog-test-container').html('<input type="' + oldType + '" />').trigger("create");
|
2011-12-09 20:51:38 +00:00
|
|
|
|
2011-12-09 20:52:53 +00:00
|
|
|
same($('#dialog-test-container input').attr("type"), newType, "type attr on dialog is: " + newType);
|
|
|
|
|
});
|
2011-12-09 20:51:38 +00:00
|
|
|
|
2011-12-09 20:52:53 +00:00
|
|
|
start();
|
|
|
|
|
}
|
|
|
|
|
]);
|
2011-12-09 20:51:38 +00:00
|
|
|
});
|
2011-10-13 20:21:47 +00:00
|
|
|
})(jQuery);
|