From bc6cfbfb53170c6f27c6b15cce0da6467a079cd4 Mon Sep 17 00:00:00 2001 From: Ghislain Seguin Date: Thu, 12 Jan 2012 23:19:36 -0800 Subject: [PATCH 1/3] Added jQuery as a param to the define shim --- js/jquery.mobile.define.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/jquery.mobile.define.js b/js/jquery.mobile.define.js index ee6d6610..2c644f41 100644 --- a/js/jquery.mobile.define.js +++ b/js/jquery.mobile.define.js @@ -1,5 +1,5 @@ // creates the define method on window, only used where async loading // is not desired in the docs and experiments window.define = function(){ - Array.prototype.slice.call(arguments).pop()(); + Array.prototype.slice.call( arguments ).pop()( window.jQuery ); }; From e6fb1e7c8e31f7d5edf24278c2b1dd51c005aea2 Mon Sep 17 00:00:00 2001 From: Ghislain Seguin Date: Thu, 12 Jan 2012 23:19:58 -0800 Subject: [PATCH 2/3] Hopefully made the event tests a little happier --- tests/unit/event/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/unit/event/index.html b/tests/unit/event/index.html index f0aeaae2..63392a80 100644 --- a/tests/unit/event/index.html +++ b/tests/unit/event/index.html @@ -12,6 +12,7 @@ $.testHelper.setPushState(); + From 8bbc9f8489e9f3be8dc6bf3d88bfe33808059ff4 Mon Sep 17 00:00:00 2001 From: Ghislain Seguin Date: Thu, 12 Jan 2012 23:20:55 -0800 Subject: [PATCH 3/3] Reverted to the old way (without RequireJS) until we find a way to make it work with RequireJS --- tests/unit/init/index.html | 21 ++--- tests/unit/init/init_core.js | 148 ++++++++++++----------------------- 2 files changed, 59 insertions(+), 110 deletions(-) diff --git a/tests/unit/init/index.html b/tests/unit/init/index.html index 1c2a8265..0cff9c32 100644 --- a/tests/unit/init/index.html +++ b/tests/unit/init/index.html @@ -4,23 +4,16 @@ jQuery Mobile Init Test Suite - - + - - - + + + + + + diff --git a/tests/unit/init/init_core.js b/tests/unit/init/init_core.js index da46ae7a..42632afa 100644 --- a/tests/unit/init/init_core.js +++ b/tests/unit/init/init_core.js @@ -3,20 +3,15 @@ */ (function($){ var mobilePage = undefined, - libName = 'jquery.mobile.init', - coreLib = 'jquery.mobile.core', + libName = 'jquery.mobile.init.js', + coreLib = 'jquery.mobile.core.js', extendFn = $.extend, originalLoadingMessage = $.mobile.loadingMessage; setGradeA = function(value) { $.mobile.gradeA = function(){ return value; }; }, reloadCoreNSandInit = function(){ - return $.testHelper.deferredSequence([ - function() { - $.testHelper.reloadModule("../jquery.setNameSpace.js"); - }, - function () { - $.testHelper.reloadModule(libName); - } - ]); + $.testHelper.reloadLib(coreLib); + $.testHelper.reloadLib("jquery.setNamespace.js"); + $.testHelper.reloadLib(libName); }; @@ -61,40 +56,27 @@ initFired = true; }); + $.testHelper.reloadLib(libName); - $.testHelper.deferredSequence([ - function() { - return $.testHelper.reloadModule(libName); - }, - - function() { - setTimeout(function(){ - ok(initFired, "init fired"); - start(); - }, 1000); - } - ]); + setTimeout(function(){ + ok(initFired, "init fired"); + start(); + }, 1000); }); - asyncTest( "enhancments are skipped when the browser is not grade A", function(){ + test( "enhancments are skipped when the browser is not grade A", function(){ setGradeA(false); - $.testHelper.reloadModule(libName).done( - function() { - //NOTE easiest way to check for enhancements, not the most obvious - ok(!$("html").hasClass("ui-mobile"), "html elem doesn't have class ui-mobile"); - start(); - } - ); + $.testHelper.reloadLib(libName); + + //NOTE easiest way to check for enhancements, not the most obvious + ok(!$("html").hasClass("ui-mobile"), "html elem doesn't have class ui-mobile"); }); - asyncTest( "enhancments are added when the browser is grade A", function(){ + test( "enhancments are added when the browser is grade A", function(){ setGradeA(true); - $.testHelper.reloadModule(libName).done( - function() { - ok($("html").hasClass("ui-mobile"), "html elem has class mobile"); - start(); - } - ); + $.testHelper.reloadLib(libName); + + ok($("html").hasClass("ui-mobile"), "html elem has class mobile"); }); asyncTest( "useFastClick is configurable via mobileinit", function(){ @@ -103,12 +85,10 @@ start(); }); - $.testHelper.reloadModule(libName).done( - function() { - same( $.mobile.useFastClick, false , "fast click is set to false after init" ); - $.mobile.useFastClick = true; - } - ); + $.testHelper.reloadLib(libName); + + same( $.mobile.useFastClick, false , "fast click is set to false after init" ); + $.mobile.useFastClick = true; }); @@ -117,47 +97,35 @@ return $(":jqmData(role='page')").first(); }; - asyncTest( "active page and start page should be set to the fist page in the selected set", function(){ + test( "active page and start page should be set to the fist page in the selected set", function(){ expect( 2 ); - $.testHelper.reloadModule(libName).done( - function() { - var firstPage = findFirstPage(); + $.testHelper.reloadLib(libName); + var firstPage = findFirstPage(); - same($.mobile.firstPage[0], firstPage[0]); - same($.mobile.activePage[0], firstPage[0]); - start(); - } - ); + same($.mobile.firstPage[0], firstPage[0]); + same($.mobile.activePage[0], firstPage[0]); }); - asyncTest( "mobile viewport class is defined on the first page's parent", function(){ + test( "mobile viewport class is defined on the first page's parent", function(){ expect( 1 ); - $.testHelper.reloadModule(libName).done( - function() { - var firstPage = findFirstPage(); + $.testHelper.reloadLib(libName); + var firstPage = findFirstPage(); - ok(firstPage.parent().hasClass("ui-mobile-viewport"), "first page has viewport"); - start(); - } - ); + ok(firstPage.parent().hasClass("ui-mobile-viewport"), "first page has viewport"); }); - asyncTest( "mobile page container is the first page's parent", function(){ + test( "mobile page container is the first page's parent", function(){ expect( 1 ); - $.testHelper.reloadModule(libName).done( - function() { - var firstPage = findFirstPage(); + $.testHelper.reloadLib(libName); + var firstPage = findFirstPage(); - same($.mobile.pageContainer[0], firstPage.parent()[0]); - start(); - } - ); + same($.mobile.pageContainer[0], firstPage.parent()[0]); }); asyncTest( "hashchange triggered on document ready with single argument: true", function(){ $.testHelper.sequence([ function(){ - $.testHelper.openPage( "#foo" ); + location.hash = "#foo"; }, // delay the bind until the first hashchange @@ -169,7 +137,7 @@ }, function(){ - return $.testHelper.reloadModule(libName); + $.testHelper.reloadLib(libName); } ], 1000); }); @@ -217,38 +185,24 @@ asyncTest( "page loading should contain default loading message", function(){ expect( 1 ); + reloadCoreNSandInit(); + $.mobile.showPageLoadingMsg(); - $.testHelper.deferredSequence([ - function() { - return $.testHelper.reloadModule(libName); - }, - function() { - $.mobile.showPageLoadingMsg(); - - setTimeout(function(){ - same($(".ui-loader h1").text(), "loading"); - start(); - }, 500); - } - ]); + setTimeout(function(){ + same($(".ui-loader h1").text(), "loading"); + start(); + }, 500); }); asyncTest( "page loading should contain custom loading message", function(){ $.mobile.loadingMessage = "foo"; + $.testHelper.reloadLib(libName); + $.mobile.showPageLoadingMsg(); - $.testHelper.deferredSequence([ - function() { - return $.testHelper.reloadModule(libName); - }, - function() { - $.mobile.showPageLoadingMsg(); - - setTimeout(function(){ - same($(".ui-loader h1").text(), "foo"); - start(); - }, 500); - } - ]); + setTimeout(function(){ + same($(".ui-loader h1").text(), "foo"); + start(); + }, 500); }); asyncTest( "page loading should contain custom loading message when set during runtime", function(){ @@ -262,8 +216,10 @@ }); + // NOTE: the next two tests work on timeouts that assume a page will be created within 2 seconds // it'd be great to get these using a more reliable callback or event + asyncTest( "page does auto-initialize at domready when autoinitialize option is true (default) ", function(){ $( "
", { "data-nstest-role": "page", "id": "autoinit-on" } ).prependTo( "body" )