Tokentextarea: Fix issues
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.1.0 / tests / unit / listview / listview_core.js
1 /*
2  * mobile listview unit tests
3  */
4
5 // TODO split out into seperate test files
6 (function($){
7         var home = $.mobile.path.parseUrl( location.href ).pathname + location.search,
8                 insetVal = $.mobile.listview.prototype.options.inset;
9
10         $.mobile.defaultTransition = "none";
11
12         module( "Basic Linked list", {
13                 setup: function(){
14                         if( location.hash != "#basic-linked-test" ){
15                                 stop();
16
17                                 $(document).one("pagechange", function() {
18                                         start();
19                                 });
20
21                                 $.mobile.changePage( home );
22                         }
23                 },
24
25                 teardown: function() {
26                         $.mobile.listview.prototype.options.inset = insetVal;
27                 }
28         });
29
30         asyncTest( "The page should enhanced correctly", function(){
31                 setTimeout(function() {
32                         ok($('#basic-linked-test .ui-li').length, ".ui-li classes added to li elements");
33                         start();
34                 }, 800);
35         });
36
37         asyncTest( "Slides to the listview page when the li a is clicked", function() {
38                 $.testHelper.pageSequence([
39                         function(){
40                                 $.mobile.changePage("#basic-linked-test");
41                         },
42
43                         function(){
44                                 $('#basic-linked-test li a').first().click();
45                         },
46
47                         function(){
48                                 ok($('#basic-link-results').hasClass('ui-page-active'));
49                                 start();
50                         }
51                 ]);
52         });
53
54         asyncTest( "Slides back to main page when back button is clicked", function() {
55                 $.testHelper.pageSequence([
56                         function(){
57                                 $.mobile.changePage("#basic-link-results");
58                         },
59
60                         function(){
61                                 window.history.back();
62                         },
63
64                         function(){
65                                 ok($('#basic-linked-test').hasClass('ui-page-active'));
66                                 start();
67                         }
68                 ]);
69         });
70
71         asyncTest( "Presence of ui-li-has- classes", function(){
72                 $.testHelper.pageSequence( [
73                         function() {
74                                 $.mobile.changePage( "#ui-li-has-test" );
75                         },
76
77                         function() {
78                                 var page = $( ".ui-page-active" ),
79                                         items = page.find( "li" );
80
81                                 ok(  items.eq( 0 ).hasClass( "ui-li-has-count"), "First LI should have ui-li-has-count class" );
82                                 ok(  items.eq( 0 ).hasClass( "ui-li-has-arrow"), "First LI should have ui-li-has-arrow class" );
83                                 ok( !items.eq( 1 ).hasClass( "ui-li-has-count"), "Second LI should NOT have ui-li-has-count class" );
84                                 ok(  items.eq( 1 ).hasClass( "ui-li-has-arrow"), "Second LI should have ui-li-has-arrow class" );
85                                 ok( !items.eq( 2 ).hasClass( "ui-li-has-count"), "Third LI should NOT have ui-li-has-count class" );
86                                 ok( !items.eq( 2 ).hasClass( "ui-li-has-arrow"), "Third LI should NOT have ui-li-has-arrow class" );
87                                 ok(  items.eq( 3 ).hasClass( "ui-li-has-count"), "Fourth LI should have ui-li-has-count class" );
88                                 ok( !items.eq( 3 ).hasClass( "ui-li-has-arrow"), "Fourth LI should NOT have ui-li-has-arrow class" );
89                                 ok( !items.eq( 4 ).hasClass( "ui-li-has-count"), "Fifth LI should NOT have ui-li-has-count class" );
90                                 ok( !items.eq( 4 ).hasClass( "ui-li-has-arrow"), "Fifth LI should NOT have ui-li-has-arrow class" );
91                                 start();
92                         }
93                 ]);
94         });
95
96         module('Nested List Test');
97
98         asyncTest( "Changes page to nested list test and enhances", function() {
99                 $.testHelper.pageSequence([
100                         function(){
101                                 $.mobile.changePage("#nested-list-test");
102                         },
103
104                         function(){
105                                 ok($('#nested-list-test').hasClass('ui-page-active'), "makes nested list test page active");
106                                 ok($(':jqmData(url="nested-list-test&ui-page=0-0")').length == 1, "Adds first UL to the page");
107                                 ok($(':jqmData(url="nested-list-test&ui-page=0-1")').length == 1, "Adds second nested UL to the page");
108                                 start();
109                         }
110                 ]);
111         });
112
113         asyncTest( "change to nested page when the li a is clicked", function() {
114
115                 $.testHelper.pageSequence([
116                         function(){
117                                 $.mobile.changePage("#nested-list-test");
118                         },
119
120                         function(){
121                                 $('.ui-page-active li:eq(1) a:eq(0)').click();
122                         },
123
124                         function(){
125                                 var $new_page = $(':jqmData(url="nested-list-test&ui-page=0-0")');
126
127                                 ok($new_page.hasClass('ui-page-active'), 'Makes the nested page the active page.');
128                                 ok($('.ui-listview', $new_page).find(":contains('Rhumba of rattlesnakes')").length == 1, "The current page should have the proper text in the list.");
129                                 ok($('.ui-listview', $new_page).find(":contains('Shoal of Bass')").length == 1, "The current page should have the proper text in the list.");
130                                 start();
131                         }
132                 ]);
133         });
134
135         asyncTest( "should go back to top level when the back button is clicked", function() {
136                 $.testHelper.pageSequence([
137                         function(){
138                                 $.mobile.changePage("#nested-list-test&ui-page=0-0");
139                         },
140
141                         function(){
142                                 window.history.back();
143                         },
144
145                         function(){
146                                 ok($('#nested-list-test').hasClass('ui-page-active'), 'Transitions back to the parent nested page');
147                                 start();
148                         }
149                 ]);
150         });
151
152         test( "nested list title should use first text node, regardless of line breaks", function(){
153                 // NOTE this is a super fragile reference to the nested page, any change to the list will break it
154                 ok($(":jqmData(url='nested-list-test&ui-page=0-0') .ui-title").text() === "More animals", 'Text should be "More animals"');
155         });
156
157         asyncTest( "Multiple nested lists on a page with same labels", function() {
158                 $.testHelper.pageSequence([
159                         function(){
160                                 // https://github.com/jquery/jquery-mobile/issues/1617
161                                 $.mobile.changePage("#nested-lists-test");
162                         },
163
164                         function(){
165                                 // Click on the link of the third li element
166                                 $('.ui-page-active li:eq(2) a:eq(0)').click();
167                         },
168
169                         function(){
170                                 equal($('.ui-page-active .ui-content .ui-listview li').text(), "Item A-3-0Item A-3-1Item A-3-2", 'Text should be "Item A-3-0Item A-3-1Item A-3-2"');
171                                 start();
172                         }
173                 ]);
174         });
175
176         module('Ordered Lists');
177
178         asyncTest( "changes to the numbered list page and enhances it", function() {
179                 $.testHelper.pageSequence([
180                         function(){
181                                 $.mobile.changePage("#numbered-list-test");
182                         },
183
184                         function(){
185                                 var $new_page = $('#numbered-list-test');
186                                 ok($new_page.hasClass('ui-page-active'), "Makes the new page active when the hash is changed.");
187                                 ok($('.ui-link-inherit', $new_page).first().text() == "Number 1", "The text of the first LI should be Number 1");
188                                 start();
189                         }
190                 ]);
191         });
192
193         asyncTest( "changes to number 1 page when the li a is clicked", function() {
194                 $.testHelper.pageSequence([
195                         function(){
196                                 $('#numbered-list-test li a').first().click();
197                         },
198
199                         function(){
200                                 ok($('#numbered-list-results').hasClass('ui-page-active'), "The new numbered page was transitioned correctly.");
201                                 start();
202                         }
203                 ]);
204         });
205
206         asyncTest( "takes us back to the numbered list when the back button is clicked", function() {
207                 $.testHelper.pageSequence([
208                         function(){
209                                 $.mobile.changePage('#numbered-list-test');
210                         },
211
212                         function(){
213                                 $.mobile.changePage('#numbered-list-results');
214                         },
215
216                         function(){
217                                 window.history.back();
218                         },
219
220                         function(){
221                                 ok($('#numbered-list-test').hasClass('ui-page-active'));
222                                 start();
223                         }
224                 ]);
225         });
226
227         module('Read only list');
228
229         asyncTest( "changes to the read only page when hash is changed", function() {
230                 $.testHelper.pageSequence([
231                         function(){
232                                 $.mobile.changePage("#read-only-list-test");
233                         },
234
235                         function(){
236                                 var $new_page = $('#read-only-list-test');
237                                 ok($new_page.hasClass('ui-page-active'), "makes the read only page the active page");
238                                 ok($('li', $new_page).first().text() === "Read", "The first LI has the proper text.");
239                                 start();
240                         }
241                 ]);
242         });
243
244         module('Split view list');
245
246         asyncTest( "changes the page to the split view list and enhances it correctly.", function() {
247                 $.testHelper.pageSequence([
248                         function(){
249                                 $.mobile.changePage("#split-list-test");
250                         },
251
252                         function(){
253                                 var $new_page = $('#split-list-test');
254                                 ok($('.ui-li-link-alt', $new_page).length == 3);
255                                 ok($('.ui-link-inherit', $new_page).length == 3);
256                                 start();
257                         }
258                 ]);
259         });
260
261         asyncTest( "change the page to the split view page 1 when the first link is clicked", function() {
262                 $.testHelper.pageSequence([
263                         function(){
264                                 $.mobile.changePage("#split-list-test");
265                         },
266
267                         function(){
268                                 $('.ui-page-active .ui-li a:eq(0)').click();
269                         },
270
271                         function(){
272                                 ok($('#split-list-link1').hasClass('ui-page-active'));
273                                 start();
274                         }
275                 ]);
276         });
277
278         asyncTest( "Slide back to the parent list view when the back button is clicked", function() {
279                 $.testHelper.pageSequence([
280                         function(){
281                                 $.mobile.changePage("#split-list-test");
282                         },
283
284                         function(){
285                                 $('.ui-page-active .ui-listview a:eq(0)').click();
286                         },
287
288                         function(){
289                                 history.back();
290                         },
291
292                         function(){
293                                 ok($('#split-list-test').hasClass('ui-page-active'));
294                                 start();
295                         }
296                 ]);
297         });
298
299         asyncTest( "Clicking on the icon (the second link) should take the user to other a href of this LI", function() {
300                 $.testHelper.pageSequence([
301                         function(){
302                                 $.mobile.changePage("#split-list-test");
303                         },
304
305                         function(){
306                                 $('.ui-page-active .ui-li-link-alt:eq(0)').click();
307                         },
308
309                         function(){
310                                 ok($('#split-list-link2').hasClass('ui-page-active'));
311                                 start();
312                         }
313                 ]);
314         });
315
316         module( "List Dividers" );
317
318         asyncTest( "Makes the list divider page the active page and enhances it correctly.", function() {
319                 $.testHelper.pageSequence([
320                         function(){
321                                 $.mobile.changePage("#list-divider-test");
322                         },
323
324                         function(){
325                                 var $new_page = $('#list-divider-test');
326                                 ok($new_page.find('.ui-li-divider').length == 2);
327                                 ok($new_page.hasClass('ui-page-active'));
328                                 start();
329                         }
330                 ]);
331         });
332
333         module( "Search Filter");
334
335         var searchFilterId = "#search-filter-test";
336
337
338         asyncTest( "Filter downs results when the user enters information", function() {
339                 var $searchPage = $(searchFilterId);
340                 $.testHelper.pageSequence([
341                         function() {
342                                 $.mobile.changePage(searchFilterId);
343                         },
344
345                         function() {
346                                 $searchPage.find('input').val('at');
347                                 $searchPage.find('input').trigger('change');
348
349                                 same($searchPage.find('li.ui-screen-hidden').length, 2);
350                                 start();
351                         }
352                 ]);
353         });
354
355         asyncTest( "Redisplay results when user removes values", function() {
356                 var $searchPage = $(searchFilterId);
357                 $.testHelper.pageSequence([
358                         function() {
359                                 $.mobile.changePage(searchFilterId);
360                         },
361
362                         function() {
363                                 $searchPage.find('input').val('a');
364                                 $searchPage.find('input').trigger('change');
365
366                                 same($searchPage.find("li[style^='display: none;']").length, 0);
367                                 start();
368                         }
369                 ]);
370         });
371
372     asyncTest( "Filter works fine with \\W- or regexp-special-characters", function() {
373         var $searchPage = $(searchFilterId);
374         $.testHelper.pageSequence([
375             function() {
376                 $.mobile.changePage(searchFilterId);
377             },
378
379             function() {
380                 $searchPage.find('input').val('*');
381                 $searchPage.find('input').trigger('change');
382
383                 same($searchPage.find('li.ui-screen-hidden').length, 4);
384                 start();
385             }
386         ]);
387     });
388
389         test( "Refresh applies thumb styling", function(){
390                 var ul = $('.ui-page-active ul');
391
392                 ul.append("<li id='fiz'><img/></li>");
393                 ok(!ul.find("#fiz img").hasClass("ui-li-thumb"));
394                 ul.listview('refresh');
395                 ok(ul.find("#fiz img").hasClass("ui-li-thumb"));
396         });
397
398         asyncTest( "Filter downs results and dividers when the user enters information", function() {
399                 var     $searchPage = $("#search-filter-with-dividers-test");
400                 $.testHelper.pageSequence([
401                         function() {
402                                 $.mobile.changePage("#search-filter-with-dividers-test");
403                         },
404
405                         // wait for the page to become active/enhanced
406                         function(){
407                                 $searchPage.find('input').val('at');
408                                 $searchPage.find('input').trigger('change');
409                                 setTimeout(function() {
410                                         //there should be four hidden list entries
411                                         same($searchPage.find('li.ui-screen-hidden').length, 4);
412
413                                         //there should be two list entries that are list dividers and hidden
414                                         same($searchPage.find('li.ui-screen-hidden:jqmData(role=list-divider)').length, 2);
415
416                                         //there should be two list entries that are not list dividers and hidden
417                                         same($searchPage.find('li.ui-screen-hidden:not(:jqmData(role=list-divider))').length, 2);
418                                         start();
419                                 }, 1000);
420                         }
421                 ]);
422         });
423
424         asyncTest( "Redisplay results when user removes values", function() {
425                 $.testHelper.pageSequence([
426                         function() {
427                                 $.mobile.changePage("#search-filter-with-dividers-test");
428                         },
429
430                         function() {
431                                 $('.ui-page-active input').val('a');
432                                 $('.ui-page-active input').trigger('change');
433
434                                 setTimeout(function() {
435                                         same($('.ui-page-active input').val(), 'a');
436                                         same($('.ui-page-active li[style^="display: none;"]').length, 0);
437                                         start();
438                                 }, 1000);
439                         }
440                 ]);
441         });
442
443         asyncTest( "Dividers are hidden when preceding hidden rows and shown when preceding shown rows", function () {
444                 $.testHelper.pageSequence([
445                         function() {
446                                 $.mobile.changePage("#search-filter-with-dividers-test");
447                         },
448
449                         function() {
450                                 var $page = $('.ui-page-active');
451
452                                 $page.find('input').val('at');
453                                 $page.find('input').trigger('change');
454
455                                 setTimeout(function() {
456                                         same($page.find('li:jqmData(role=list-divider):hidden').length, 2);
457                                         same($page.find('li:jqmData(role=list-divider):hidden + li:not(:jqmData(role=list-divider)):hidden').length, 2);
458                                         same($page.find('li:jqmData(role=list-divider):not(:hidden) + li:not(:jqmData(role=list-divider)):not([:hidden)').length, 2);
459                                         start();
460                                 }, 1000);
461                         }
462                 ]);
463         });
464
465         asyncTest( "Inset List View should refresh corner classes after filtering", 4 * 2, function () {
466                 var checkClasses = function() {
467                         var $page = $( ".ui-page-active" ),
468                                 $li = $page.find( "li:visible" );
469                         ok($li.first().hasClass( "ui-corner-top" ), $li.length+" li elements: First visible element should have class ui-corner-top");
470                         ok($li.last().hasClass( "ui-corner-bottom" ), $li.length+" li elements: Last visible element should have class ui-corner-bottom");
471                 };
472
473                 $.testHelper.pageSequence([
474                         function() {
475                                 $.mobile.changePage("#search-filter-inset-test");
476                         },
477
478                         function() {
479                                 var $page = $('.ui-page-active');
480                                 $.testHelper.sequence([
481                                         function() {
482                                                 checkClasses();
483
484                                                 $page.find('input').val('man');
485                                                 $page.find('input').trigger('change');
486                                         },
487
488                                         function() {
489                                                 checkClasses();
490
491                                                 $page.find('input').val('at');
492                                                 $page.find('input').trigger('change');
493                                         },
494
495                                         function() {
496                                                 checkClasses();
497
498                                                 $page.find('input').val('catwoman');
499                                                 $page.find('input').trigger('change');
500                                         },
501
502                                         function() {
503                                                 checkClasses();
504                                                 start();
505                                         }
506                                 ], 50);
507                         }
508                 ]);
509         });
510
511         module( "Programmatically generated list items", {
512                 setup: function(){
513                         var item,
514                                 data = [
515                                         {
516                                                 id: 1,
517                                                 label: "Item 1"
518                                         },
519                                         {
520                                                 id: 2,
521                                                 label: "Item 2"
522                                         },
523                                         {
524                                                 id: 3,
525                                                 label: "Item 3"
526                                         },
527                                         {
528                                                 id: 4,
529                                                 label: "Item 4"
530                                         }
531                                 ];
532
533                         $( "#programmatically-generated-list-items" ).html("");
534
535                         for ( var i = 0, len = data.length; i < len; i++ ) {
536                                 item = $( '<li id="myItem' + data[i].id + '">' );
537                                 label = $( "<strong>" + data[i].label + "</strong>").appendTo( item );
538                                 $( "#programmatically-generated-list-items" ).append( item );
539                         }
540                 }
541         });
542
543         asyncTest( "Corner styling on programmatically created list items", function() {
544                 // https://github.com/jquery/jquery-mobile/issues/1470
545                 $.testHelper.pageSequence([
546                         function() {
547                                 $.mobile.changePage( "#programmatically-generated-list" );
548                         },
549                         function() {
550                                 ok(!$( "#programmatically-generated-list-items li:first-child" ).hasClass( "ui-corner-bottom" ), "First list item should not have class ui-corner-bottom" );
551                                 start();
552                         }
553                 ]);
554         });
555
556         module("Programmatic list items manipulation");
557
558         asyncTest("Removing list items", 4, function() {
559                 $.testHelper.pageSequence([
560                         function() {
561                                 $.mobile.changePage("#removing-items-from-list-test");
562                         },
563
564                         function() {
565                                 var ul = $('#removing-items-from-list-test ul');
566                                 ul.find("li").first().remove();
567                                 equal(ul.find("li").length, 3, "There should be only 3 list items left");
568
569                                 ul.listview('refresh');
570                                 ok(ul.find("li").first().hasClass("ui-corner-top"), "First list item should have class ui-corner-top");
571
572                                 ul.find("li").last().remove();
573                                 equal(ul.find("li").length, 2, "There should be only 2 list items left");
574
575                                 ul.listview('refresh');
576                                 ok(ul.find("li").last().hasClass("ui-corner-bottom"), "Last list item should have class ui-corner-bottom");
577                                 start();
578                         }
579                 ]);
580         });
581
582         module("Rounded corners");
583
584         asyncTest("Top and bottom corners rounded in inset list", 14, function() {
585                 $.testHelper.pageSequence([
586                         function() {
587                                 $.mobile.changePage("#corner-rounded-test");
588                         },
589
590                         function() {
591                                 var ul = $('#corner-rounded-test ul');
592
593                                 for( var t = 0; t<3; t++){
594                                         ul.append("<li>Item " + t + "</li>");
595                                         ul.listview('refresh');
596                                         equals(ul.find(".ui-corner-top").length, 1, "There should be only one element with class ui-corner-top");
597                                         equals(ul.find("li:visible").first()[0], ul.find(".ui-corner-top")[0], "First list item should have class ui-corner-top in list with " + ul.find("li").length + " item(s)");
598                                         equals(ul.find(".ui-corner-bottom").length, 1, "There should be only one element with class ui-corner-bottom");
599                                         equals(ul.find("li:visible").last()[0], ul.find(".ui-corner-bottom")[0], "Last list item should have class ui-corner-bottom in list with " + ul.find("li").length + " item(s)");
600                                 }
601
602                                 ul.find( "li" ).first().hide();
603                                 ul.listview( "refresh" );
604                                 equals(ul.find("li:visible").first()[0], ul.find(".ui-corner-top")[0], "First visible list item should have class ui-corner-top");
605
606                                 ul.find( "li" ).last().hide();
607                                 ul.listview( "refresh" );
608                                 equals(ul.find("li:visible").last()[0], ul.find(".ui-corner-bottom")[0], "Last visible list item should have class ui-corner-bottom");
609
610                                 start();
611                         }
612                 ]);
613         });
614
615         test( "Listview will create when inside a container that receives a 'create' event", function(){
616                 ok( !$("#enhancetest").appendTo(".ui-page-active").find(".ui-listview").length, "did not have enhancements applied" );
617                 ok( $("#enhancetest").trigger("create").find(".ui-listview").length, "enhancements applied" );
618         });
619
620         module( "Cached Linked List" );
621
622         var findNestedPages = function(selector){
623                 return $( selector + " #topmost" ).listview( 'childPages' );
624         };
625
626         asyncTest( "nested pages are removed from the dom by default", function(){
627                 $.testHelper.pageSequence([
628                         function(){
629                                 //reset for relative url refs
630                                 $.mobile.changePage( home );
631                         },
632
633                         function(){
634                                 $.mobile.changePage( "cache-tests/uncached-nested.html" );
635                         },
636
637                         function(){
638                                 ok( findNestedPages( "#uncached-nested-list" ).length > 0, "verify that there are nested pages" );
639                                 $.mobile.changePage( home );
640                         },
641
642                         function() {
643                                 $.mobile.changePage( "cache-tests/clear.html" );
644                         },
645
646                         function(){
647                                 same( findNestedPages( "#uncached-nested-list" ).length, 0 );
648                                 start();
649                         }
650                 ]);
651         });
652
653         asyncTest( "nested pages preserved when parent page is cached", function(){
654
655                 $.testHelper.pageSequence([
656                         function(){
657                                 //reset for relative url refs
658                                 $.mobile.changePage( home );
659                         },
660
661                         function(){
662                                 $.mobile.changePage( "cache-tests/cached-nested.html" );
663                         },
664
665                         function(){
666                                 ok( findNestedPages( "#cached-nested-list" ).length > 0, "verify that there are nested pages" );
667                                 $.mobile.changePage( home );
668                         },
669
670                         function() {
671                                 $.mobile.changePage( "cache-tests/clear.html" );
672                         },
673
674                         function(){
675                                 ok( findNestedPages( "#cached-nested-list" ).length > 0, "nested pages remain" );
676                                 start();
677                         }
678                 ]);
679         });
680
681         asyncTest( "parent page is not removed when visiting a sub page", function(){
682                 $.testHelper.pageSequence([
683                         function(){
684                                 //reset for relative url refs
685                                 $.mobile.changePage( home );
686                         },
687
688                         function(){
689                                 $.mobile.changePage( "cache-tests/cached-nested.html" );
690                         },
691
692                         function(){
693                                 same( $("#cached-nested-list").length, 1 );
694                                 $.mobile.changePage( home );
695                         },
696
697                         function() {
698                                 $.mobile.changePage( "cache-tests/clear.html" );
699                         },
700
701                         function(){
702                                 same( $("#cached-nested-list").length, 1 );
703                                 start();
704                         }
705                 ]);
706         });
707
708         asyncTest( "filterCallback can be altered after widget creation", function(){
709                 var listPage = $( "#search-filter-test" );
710                 expect( listPage.find("li").length );
711
712                 $.testHelper.pageSequence( [
713                         function(){
714                                 //reset for relative url refs
715                                 $.mobile.changePage( home );
716                         },
717
718                         function() {
719                                 $.mobile.changePage( "#search-filter-test" );
720                         },
721
722                         function() {
723                                 // set the listview instance callback
724                                 listPage.find( "ul" ).listview( "option", "filterCallback", function() {
725                                         ok(true, "custom callback invoked");
726                                 });
727
728                                 // trigger a change in the search filter
729                                 listPage.find( "input" ).val( "foo" ).trigger( "change" );
730
731                                 //NOTE beware a poossible issue with timing here
732                                 start();
733                         }
734                 ]);
735         });
736
737         asyncTest( "nested pages hash key is always in the hash (replaceState)", function(){
738                 $.testHelper.pageSequence([
739                         function(){
740                                 //reset for relative url refs
741                                 $.mobile.changePage( home );
742                         },
743
744                         function(){
745                                 // https://github.com/jquery/jquery-mobile/issues/1617
746                                 $.mobile.changePage("#nested-lists-test");
747                         },
748
749                         function(){
750                                 // Click on the link of the third li element
751                                 $('.ui-page-active li:eq(2) a:eq(0)').click();
752                         },
753
754                         function(){
755                                 ok( location.hash.search($.mobile.subPageUrlKey) >= 0 );
756                                 start();
757                         }
758                 ]);
759         });
760
761         asyncTest( "embedded listview page with nested pages is not removed from the dom", function() {
762                 $.testHelper.pageSequence([
763                         function() {
764                                 // open the nested list page
765                                 same( $("div#nested-list-test").length, 1 );
766                                 $( "a#nested-list-test-anchor" ).click();
767                         },
768
769                         function() {
770                                 // go back to the origin page
771                                 window.history.back();
772                         },
773
774                         function() {
775                                 // make sure the page is still in place
776                                 same( $("div#nested-list-test").length, 1 );
777                                 start();
778                         }
779                 ]);
780         });
781
782
783         asyncTest( "list inherits theme from parent", function() {
784                 $.testHelper.pageSequence([
785                         function() {
786                                 $.mobile.changePage("#list-theme-inherit");
787                         },
788
789                         function() {
790                                 var theme = $.mobile.activePage.jqmData('theme');
791                                 ok( $.mobile.activePage.find("ul > li").hasClass("ui-body-b"), "theme matches the parent");
792                                 window.history.back();
793                         },
794
795                         start
796                 ]);
797         });
798
799         asyncTest( "list filter is inset from prototype options value", function() {
800                 $.mobile.listview.prototype.options.inset = true;
801                 $("#list-inset-filter-prototype").page();
802
803                 $.testHelper.pageSequence([
804                         function() {
805                                 $.mobile.changePage("#list-inset-filter-prototype");
806                         },
807
808                         function( timedOut) {
809                                 ok( !timedOut );
810                                 same( $.mobile.activePage.find("form.ui-listview-filter-inset").length, 1, "form is inset");
811                                 window.history.back();
812                         },
813
814                         start
815                 ]);
816         });
817
818         asyncTest( "list filter is inset from data attr value", function() {
819                 $.mobile.listview.prototype.options.inset = false;
820                 $("#list-inset-filter-data-attr").page();
821
822                 $.testHelper.pageSequence([
823                         function() {
824                                 $.mobile.changePage("#list-inset-filter-data-attr");
825                         },
826
827                         function( timedOut) {
828                                 ok( !timedOut );
829                                 same( $.mobile.activePage.find("form.ui-listview-filter-inset").length, 1, "form is inset");
830                                 window.history.back();
831                         },
832
833                         start
834                 ]);
835         });
836
837         asyncTest( "split list items respect the icon", function() {
838                 $.testHelper.pageSequence([
839                         function() {
840                                 $.mobile.changePage("#split-list-icon");
841                         },
842
843                         function() {
844                                 $.mobile.activePage.find("li").each(function(i, elem){
845                                         var $elem = $(elem),
846                                                 order = [ "star", "plug", "delete", "plug" ];
847
848                                         same( $elem.find("span.ui-icon-" + order[i]).length, 1, "there should be one " + order[i] + " icon" );
849                                 });
850
851                                 window.history.back();
852                         },
853
854                         start
855                 ]);
856         });
857 })(jQuery);