document ready tests are finished

This commit is contained in:
John Bender 2010-11-26 16:35:23 +08:00 committed by Scott Jehl
parent 2913104d4f
commit 3df0060827
2 changed files with 62 additions and 17 deletions

View file

@ -32,6 +32,19 @@
//NOTE append "cache breaker" to force reload
lib.attr('src', src + "?" + this.reloads[libName].count++);
$("body").append(lib);
},
alterExtend: function(extraExtension){
var extendFn = $.extend;
$.extend = function(object, extension){
// NOTE extend the object as normal
var result = extendFn.apply(this, arguments);
// NOTE add custom extensions
result = extendFn(result, extraExtension);
return result;
};
}
};
})(jQuery);

View file

@ -56,29 +56,17 @@
ok($("html").hasClass("ui-mobile"));
});
var alterExtend = function(extraExtension){
var extendFn = $.extend;
$.extend = function(object, extension){
// NOTE extend the object as normal
var result = extendFn.apply(this, arguments);
// NOTE add custom extensions
result = extendFn(result, extraExtension);
return result;
};
};
//TODO lots of duplication
test( "pageLoading doesn't add the dialog to the page when loading message is false", function(){
alterExtend({loadingMessage: false});
$.testHelper.alterExtend({loadingMessage: false});
$.testHelper.reloadLib(libName);
$.mobile.pageLoading(false);
ok(!$(".ui-loader").length);
});
test( "pageLoading doesn't add the dialog to the page when done is passed as true", function(){
alterExtend({loadingMessage: true});
$.testHelper.alterExtend({loadingMessage: true});
$.testHelper.reloadLib(libName);
// TODO add post reload callback
@ -89,7 +77,7 @@
});
test( "pageLoading adds the dialog to the page when done is true", function(){
alterExtend({loadingMessage: true});
$.testHelper.alterExtend({loadingMessage: true});
$.testHelper.reloadLib(libName);
$.mobile.pageLoading(false);
ok($(".ui-loader").length);
@ -98,7 +86,7 @@
var metaViewportSelector = "head meta[name=viewport]",
setViewPortContent = function(value){
$(metaViewportSelector).remove();
alterExtend({metaViewportContent: value});
$.testHelper.alterExtend({metaViewportContent: value});
$.testHelper.reloadLib(libName);
};
@ -112,6 +100,50 @@
same($(metaViewportSelector).length, 0);
});
//TODO test the rest of the library after the $loader definition
var findFirstPage = function() {
return $("[data-role='page']").first();
};
test( "active page and start page should be set to the fist page in the selected set", function(){
var firstPage = findFirstPage();
$.testHelper.reloadLib(libName);
same($.mobile.startPage, firstPage);
same($.mobile.activePage, firstPage);
});
test( "mobile viewport class is defined on the first page's parent", function(){
var firstPage = findFirstPage();
$.testHelper.reloadLib(libName);
ok(firstPage.parent().hasClass('ui-mobile-viewport'));
});
test( "mobile page container is the first page's parent", function(){
var firstPage = findFirstPage();
$.testHelper.reloadLib(libName);
same($.mobile.pageContainer, firstPage.parent());
});
test( "page loading is called on document ready", function(){
expect( 2 );
$.testHelper.alterExtend({ pageLoading: function(){
ok("called");
}});
$.testHelper.reloadLib(libName);
});
test( "hashchange triggered on document ready with single argument: true", function(){
expect( 2 );
$(window).bind("hashchange", function(ev, arg){
same(arg, true);
});
$.testHelper.reloadLib(libName);
});
});
})(jQuery);