Skip to content

Commit d670fea

Browse files
author
scottjehl
committed
removed test for page-div-not-required, as it has its own test page.. Added tests for auto initialize option.
1 parent df3fbca commit d670fea

File tree

1 file changed

+46
-7
lines changed

1 file changed

+46
-7
lines changed

tests/unit/init/init_core.js

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,53 @@
213213
});
214214

215215

216-
asyncTest( "page element is generated when not present in ajax'd markup", function(){
217-
expect( 1 );
218-
$.mobile.changePage( "nopage.html" );
216+
217+
// NOTE: the next two tests work on timeouts that assume a page will be created within 2 seconds
218+
// it'd be great to get these using a more reliable callback or event
219+
220+
asyncTest( "page does auto-initialize at domready when autoinitialize option is true (default) ", function(){
221+
222+
$( "<div />", { "data-nstest-role": "page", "id": "autoinit-on" } ).prependTo( "body" )
223+
224+
$(document).one("mobileinit", function(){
225+
$.mobile.autoInitializePage = true;
226+
});
219227

220-
$( ":jqmData(url$='nopage.html')" ).live( "pagecreate", function(){
221-
ok(true, "page was created from dynamically loaded HTML that contained no page div" );
222-
start();
223-
} );
228+
location.hash = "";
229+
230+
reloadCoreNSandInit();
231+
232+
setTimeout(function(){
233+
same( $( "#autoinit-on.ui-page" ).length, 1 );
234+
235+
start();
236+
}, 2000);
237+
});
238+
239+
240+
asyncTest( "page does not initialize at domready when autoinitialize option is false ", function(){
241+
$(document).one("mobileinit", function(){
242+
$.mobile.autoInitializePage = false;
243+
});
244+
245+
$( "<div />", { "data-nstest-role": "page", "id": "autoinit-off" } ).prependTo( "body" )
246+
247+
location.hash = "";
248+
249+
250+
reloadCoreNSandInit();
251+
252+
setTimeout(function(){
253+
same( $( "#autoinit-off.ui-page" ).length, 0 );
254+
255+
$(document).bind("mobileinit", function(){
256+
$.mobile.autoInitializePage = true;
257+
});
258+
259+
reloadCoreNSandInit();
260+
261+
start();
262+
}, 2000);
224263
});
225264

226265

0 commit comments

Comments
 (0)