|
3 | 3 | */ |
4 | 4 | (function($){ |
5 | 5 | var mobilePage = undefined, |
6 | | - libName = 'jquery.mobile.init', |
7 | | - coreLib = 'jquery.mobile.core', |
| 6 | + libName = 'jquery.mobile.init.js', |
| 7 | + coreLib = 'jquery.mobile.core.js', |
8 | 8 | extendFn = $.extend, |
9 | 9 | originalLoadingMessage = $.mobile.loadingMessage; |
10 | 10 | setGradeA = function(value) { $.mobile.gradeA = function(){ return value; }; }, |
11 | 11 | reloadCoreNSandInit = function(){ |
12 | | - return $.testHelper.deferredSequence([ |
13 | | - function() { |
14 | | - $.testHelper.reloadModule("../jquery.setNameSpace.js"); |
15 | | - }, |
16 | | - function () { |
17 | | - $.testHelper.reloadModule(libName); |
18 | | - } |
19 | | - ]); |
| 12 | + $.testHelper.reloadLib(coreLib); |
| 13 | + $.testHelper.reloadLib("jquery.setNamespace.js"); |
| 14 | + $.testHelper.reloadLib(libName); |
20 | 15 | }; |
21 | 16 |
|
22 | 17 |
|
|
61 | 56 | initFired = true; |
62 | 57 | }); |
63 | 58 |
|
| 59 | + $.testHelper.reloadLib(libName); |
64 | 60 |
|
65 | | - $.testHelper.deferredSequence([ |
66 | | - function() { |
67 | | - return $.testHelper.reloadModule(libName); |
68 | | - }, |
69 | | - |
70 | | - function() { |
71 | | - setTimeout(function(){ |
72 | | - ok(initFired, "init fired"); |
73 | | - start(); |
74 | | - }, 1000); |
75 | | - } |
76 | | - ]); |
| 61 | + setTimeout(function(){ |
| 62 | + ok(initFired, "init fired"); |
| 63 | + start(); |
| 64 | + }, 1000); |
77 | 65 | }); |
78 | 66 |
|
79 | | - asyncTest( "enhancments are skipped when the browser is not grade A", function(){ |
| 67 | + test( "enhancments are skipped when the browser is not grade A", function(){ |
80 | 68 | setGradeA(false); |
81 | | - $.testHelper.reloadModule(libName).done( |
82 | | - function() { |
83 | | - //NOTE easiest way to check for enhancements, not the most obvious |
84 | | - ok(!$("html").hasClass("ui-mobile"), "html elem doesn't have class ui-mobile"); |
85 | | - start(); |
86 | | - } |
87 | | - ); |
| 69 | + $.testHelper.reloadLib(libName); |
| 70 | + |
| 71 | + //NOTE easiest way to check for enhancements, not the most obvious |
| 72 | + ok(!$("html").hasClass("ui-mobile"), "html elem doesn't have class ui-mobile"); |
88 | 73 | }); |
89 | 74 |
|
90 | | - asyncTest( "enhancments are added when the browser is grade A", function(){ |
| 75 | + test( "enhancments are added when the browser is grade A", function(){ |
91 | 76 | setGradeA(true); |
92 | | - $.testHelper.reloadModule(libName).done( |
93 | | - function() { |
94 | | - ok($("html").hasClass("ui-mobile"), "html elem has class mobile"); |
95 | | - start(); |
96 | | - } |
97 | | - ); |
| 77 | + $.testHelper.reloadLib(libName); |
| 78 | + |
| 79 | + ok($("html").hasClass("ui-mobile"), "html elem has class mobile"); |
98 | 80 | }); |
99 | 81 |
|
100 | 82 | asyncTest( "useFastClick is configurable via mobileinit", function(){ |
|
103 | 85 | start(); |
104 | 86 | }); |
105 | 87 |
|
106 | | - $.testHelper.reloadModule(libName).done( |
107 | | - function() { |
108 | | - same( $.mobile.useFastClick, false , "fast click is set to false after init" ); |
109 | | - $.mobile.useFastClick = true; |
110 | | - } |
111 | | - ); |
| 88 | + $.testHelper.reloadLib(libName); |
| 89 | + |
| 90 | + same( $.mobile.useFastClick, false , "fast click is set to false after init" ); |
| 91 | + $.mobile.useFastClick = true; |
112 | 92 | }); |
113 | 93 |
|
114 | 94 |
|
|
117 | 97 | return $(":jqmData(role='page')").first(); |
118 | 98 | }; |
119 | 99 |
|
120 | | - asyncTest( "active page and start page should be set to the fist page in the selected set", function(){ |
| 100 | + test( "active page and start page should be set to the fist page in the selected set", function(){ |
121 | 101 | expect( 2 ); |
122 | | - $.testHelper.reloadModule(libName).done( |
123 | | - function() { |
124 | | - var firstPage = findFirstPage(); |
| 102 | + $.testHelper.reloadLib(libName); |
| 103 | + var firstPage = findFirstPage(); |
125 | 104 |
|
126 | | - same($.mobile.firstPage[0], firstPage[0]); |
127 | | - same($.mobile.activePage[0], firstPage[0]); |
128 | | - start(); |
129 | | - } |
130 | | - ); |
| 105 | + same($.mobile.firstPage[0], firstPage[0]); |
| 106 | + same($.mobile.activePage[0], firstPage[0]); |
131 | 107 | }); |
132 | 108 |
|
133 | | - asyncTest( "mobile viewport class is defined on the first page's parent", function(){ |
| 109 | + test( "mobile viewport class is defined on the first page's parent", function(){ |
134 | 110 | expect( 1 ); |
135 | | - $.testHelper.reloadModule(libName).done( |
136 | | - function() { |
137 | | - var firstPage = findFirstPage(); |
| 111 | + $.testHelper.reloadLib(libName); |
| 112 | + var firstPage = findFirstPage(); |
138 | 113 |
|
139 | | - ok(firstPage.parent().hasClass("ui-mobile-viewport"), "first page has viewport"); |
140 | | - start(); |
141 | | - } |
142 | | - ); |
| 114 | + ok(firstPage.parent().hasClass("ui-mobile-viewport"), "first page has viewport"); |
143 | 115 | }); |
144 | 116 |
|
145 | | - asyncTest( "mobile page container is the first page's parent", function(){ |
| 117 | + test( "mobile page container is the first page's parent", function(){ |
146 | 118 | expect( 1 ); |
147 | | - $.testHelper.reloadModule(libName).done( |
148 | | - function() { |
149 | | - var firstPage = findFirstPage(); |
| 119 | + $.testHelper.reloadLib(libName); |
| 120 | + var firstPage = findFirstPage(); |
150 | 121 |
|
151 | | - same($.mobile.pageContainer[0], firstPage.parent()[0]); |
152 | | - start(); |
153 | | - } |
154 | | - ); |
| 122 | + same($.mobile.pageContainer[0], firstPage.parent()[0]); |
155 | 123 | }); |
156 | 124 |
|
157 | 125 | asyncTest( "hashchange triggered on document ready with single argument: true", function(){ |
158 | 126 | $.testHelper.sequence([ |
159 | 127 | function(){ |
160 | | - $.testHelper.openPage( "#foo" ); |
| 128 | + location.hash = "#foo"; |
161 | 129 | }, |
162 | 130 |
|
163 | 131 | // delay the bind until the first hashchange |
|
169 | 137 | }, |
170 | 138 |
|
171 | 139 | function(){ |
172 | | - return $.testHelper.reloadModule(libName); |
| 140 | + $.testHelper.reloadLib(libName); |
173 | 141 | } |
174 | 142 | ], 1000); |
175 | 143 | }); |
|
217 | 185 |
|
218 | 186 | asyncTest( "page loading should contain default loading message", function(){ |
219 | 187 | expect( 1 ); |
| 188 | + reloadCoreNSandInit(); |
| 189 | + $.mobile.showPageLoadingMsg(); |
220 | 190 |
|
221 | | - $.testHelper.deferredSequence([ |
222 | | - function() { |
223 | | - return $.testHelper.reloadModule(libName); |
224 | | - }, |
225 | | - function() { |
226 | | - $.mobile.showPageLoadingMsg(); |
227 | | - |
228 | | - setTimeout(function(){ |
229 | | - same($(".ui-loader h1").text(), "loading"); |
230 | | - start(); |
231 | | - }, 500); |
232 | | - } |
233 | | - ]); |
| 191 | + setTimeout(function(){ |
| 192 | + same($(".ui-loader h1").text(), "loading"); |
| 193 | + start(); |
| 194 | + }, 500); |
234 | 195 | }); |
235 | 196 |
|
236 | 197 | asyncTest( "page loading should contain custom loading message", function(){ |
237 | 198 | $.mobile.loadingMessage = "foo"; |
| 199 | + $.testHelper.reloadLib(libName); |
| 200 | + $.mobile.showPageLoadingMsg(); |
238 | 201 |
|
239 | | - $.testHelper.deferredSequence([ |
240 | | - function() { |
241 | | - return $.testHelper.reloadModule(libName); |
242 | | - }, |
243 | | - function() { |
244 | | - $.mobile.showPageLoadingMsg(); |
245 | | - |
246 | | - setTimeout(function(){ |
247 | | - same($(".ui-loader h1").text(), "foo"); |
248 | | - start(); |
249 | | - }, 500); |
250 | | - } |
251 | | - ]); |
| 202 | + setTimeout(function(){ |
| 203 | + same($(".ui-loader h1").text(), "foo"); |
| 204 | + start(); |
| 205 | + }, 500); |
252 | 206 | }); |
253 | 207 |
|
254 | 208 | asyncTest( "page loading should contain custom loading message when set during runtime", function(){ |
|
262 | 216 | }); |
263 | 217 |
|
264 | 218 |
|
| 219 | + |
265 | 220 | // NOTE: the next two tests work on timeouts that assume a page will be created within 2 seconds |
266 | 221 | // it'd be great to get these using a more reliable callback or event |
| 222 | + |
267 | 223 | asyncTest( "page does auto-initialize at domready when autoinitialize option is true (default) ", function(){ |
268 | 224 |
|
269 | 225 | $( "<div />", { "data-nstest-role": "page", "id": "autoinit-on" } ).prependTo( "body" ) |
|
0 commit comments