File tree Expand file tree Collapse file tree 1 file changed +46
-7
lines changed Expand file tree Collapse file tree 1 file changed +46
-7
lines changed Original file line number Diff line number Diff line change 213
213
} ) ;
214
214
215
215
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
+ } ) ;
219
227
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 ) ;
224
263
} ) ;
225
264
226
265
You can’t perform that action at this time.
0 commit comments