|
4 | 4 |
|
5 | 5 | // TODO split out into seperate test files
|
6 | 6 | (function($){
|
| 7 | + |
7 | 8 | $.mobile.defaultTransition = "none";
|
8 | 9 | module('Basic Linked list', {
|
9 | 10 | setup: function(){
|
|
19 | 20 | });
|
20 | 21 |
|
21 | 22 | asyncTest( "Slides to the listview page when the li a is clicked", function() {
|
22 |
| - $.testHelper.openPage("#basic-linked-test"); |
| 23 | + $.testHelper.pageSequence([ |
| 24 | + function(){ |
| 25 | + $.testHelper.openPage("#basic-linked-test"); |
| 26 | + }, |
23 | 27 |
|
24 |
| - setTimeout(function(){ |
25 |
| - $('#basic-linked-test li a').first().click(); |
26 |
| - }, 500); |
| 28 | + function(){ |
| 29 | + $('#basic-linked-test li a').first().click(); |
| 30 | + }, |
27 | 31 |
|
28 |
| - setTimeout(function() { |
29 |
| - ok($('#basic-link-results').hasClass('ui-page-active')); |
30 |
| - start(); |
31 |
| - }, 1000); |
| 32 | + function(){ |
| 33 | + ok($('#basic-link-results').hasClass('ui-page-active')); |
| 34 | + start(); |
| 35 | + } |
| 36 | + ]); |
32 | 37 | });
|
33 | 38 |
|
34 | 39 | asyncTest( "Slides back to main page when back button is clicked", function() {
|
35 |
| - $.testHelper.openPage("#basic-link-results"); |
| 40 | + $.testHelper.pageSequence([ |
| 41 | + function(){ |
| 42 | + $.testHelper.openPage("#basic-link-results"); |
| 43 | + }, |
36 | 44 |
|
37 |
| - window.history.back(); |
| 45 | + function(){ |
| 46 | + window.history.back(); |
| 47 | + }, |
38 | 48 |
|
39 |
| - setTimeout(function() { |
40 |
| - ok($('#basic-linked-test').hasClass('ui-page-active')); |
41 |
| - start(); |
42 |
| - }, 1000); |
| 49 | + function(){ |
| 50 | + ok($('#basic-linked-test').hasClass('ui-page-active')); |
| 51 | + start(); |
| 52 | + } |
| 53 | + ]); |
43 | 54 | });
|
44 | 55 |
|
45 | 56 | module('Nested List Test');
|
46 | 57 |
|
47 | 58 | asyncTest( "Changes page to nested list test and enhances", function() {
|
48 |
| - $.testHelper.openPage("#nested-list-test"); |
49 |
| - setTimeout(function() { |
50 |
| - ok($('#nested-list-test').hasClass('ui-page-active'), "makes nested list test page active"); |
51 |
| - ok($(':jqmData(url="nested-list-test&ui-page=More-animals-0")').length == 1, "Adds first UL to the page"); |
52 |
| - ok($(':jqmData(url="nested-list-test&ui-page=Groups-of-animals-1")').length == 1, "Adds second nested UL to the page"); |
53 |
| - start(); |
54 |
| - }, 1000); |
| 59 | + $.testHelper.pageSequence([ |
| 60 | + function(){ |
| 61 | + $.testHelper.openPage("#nested-list-test"); |
| 62 | + }, |
| 63 | + |
| 64 | + function(){ |
| 65 | + ok($('#nested-list-test').hasClass('ui-page-active'), "makes nested list test page active"); |
| 66 | + ok($(':jqmData(url="nested-list-test&ui-page=More-animals-0")').length == 1, "Adds first UL to the page"); |
| 67 | + ok($(':jqmData(url="nested-list-test&ui-page=Groups-of-animals-1")').length == 1, "Adds second nested UL to the page"); |
| 68 | + start(); |
| 69 | + } |
| 70 | + ]); |
55 | 71 | });
|
56 | 72 |
|
57 | 73 | asyncTest( "change to nested page when the li a is clicked", function() {
|
58 |
| - $.testHelper.openPage("#nested-list-test"); |
59 |
| - $('.ui-page-active li:eq(1) a:eq(0)').click(); |
60 |
| - setTimeout(function() { |
61 |
| - var $new_page = $(':jqmData(url="nested-list-test&ui-page=More-animals-0")'); |
62 | 74 |
|
63 |
| - ok($new_page.hasClass('ui-page-active'), 'Makes the nested page the active page.'); |
64 |
| - ok($('.ui-listview', $new_page).find(":contains('Rhumba of rattlesnakes')").length == 1, "The current page should have the proper text in the list."); |
65 |
| - ok($('.ui-listview', $new_page).find(":contains('Shoal of Bass')").length == 1, "The current page should have the proper text in the list."); |
66 |
| - start(); |
67 |
| - }, 1000); |
| 75 | + $.testHelper.pageSequence([ |
| 76 | + function(){ |
| 77 | + $.testHelper.openPage("#nested-list-test"); |
| 78 | + }, |
| 79 | + |
| 80 | + function(){ |
| 81 | + $('.ui-page-active li:eq(1) a:eq(0)').click(); |
| 82 | + }, |
| 83 | + |
| 84 | + function(){ |
| 85 | + var $new_page = $(':jqmData(url="nested-list-test&ui-page=More-animals-0")'); |
| 86 | + |
| 87 | + ok($new_page.hasClass('ui-page-active'), 'Makes the nested page the active page.'); |
| 88 | + ok($('.ui-listview', $new_page).find(":contains('Rhumba of rattlesnakes')").length == 1, "The current page should have the proper text in the list."); |
| 89 | + ok($('.ui-listview', $new_page).find(":contains('Shoal of Bass')").length == 1, "The current page should have the proper text in the list."); |
| 90 | + start(); |
| 91 | + } |
| 92 | + ]); |
68 | 93 | });
|
69 | 94 |
|
70 | 95 | asyncTest( "should go back to top level when the back button is clicked", function() {
|
71 |
| - $.testHelper.openPage("#nested-list-test&ui-page=More-animals-0"); |
72 |
| - window.history.back(); |
| 96 | + $.testHelper.pageSequence([ |
| 97 | + function(){ |
| 98 | + $.testHelper.openPage("#nested-list-test&ui-page=More-animals-0"); |
| 99 | + }, |
73 | 100 |
|
74 |
| - setTimeout(function() { |
75 |
| - ok($('#nested-list-test').hasClass('ui-page-active'), 'Transitions back to the parent nested page'); |
76 |
| - start(); |
77 |
| - }, 1000); |
| 101 | + function(){ |
| 102 | + window.history.back(); |
| 103 | + }, |
| 104 | + |
| 105 | + function(){ |
| 106 | + ok($('#nested-list-test').hasClass('ui-page-active'), 'Transitions back to the parent nested page'); |
| 107 | + start(); |
| 108 | + } |
| 109 | + ]); |
78 | 110 | });
|
79 | 111 |
|
80 | 112 | test( "nested list title should use first text node, regardless of line breaks", function(){
|
81 | 113 | ok($('#nested-list-test .linebreaknode').text() === "More animals", 'Text should be "More animals"');
|
82 | 114 | });
|
83 | 115 |
|
84 | 116 | asyncTest( "Multiple nested lists on a page", function() {
|
85 |
| - // https://github.com/jquery/jquery-mobile/issues/1617 |
86 |
| - $.testHelper.openPage("#nested-lists-test"); |
87 |
| - |
88 |
| - setTimeout(function() { |
89 |
| - $('.ui-page-active li:eq(2) a:eq(0)').click(); |
| 117 | + $.testHelper.pageSequence([ |
| 118 | + function(){ |
| 119 | + // https://github.com/jquery/jquery-mobile/issues/1617 |
| 120 | + $.testHelper.openPage("#nested-lists-test"); |
| 121 | + }, |
90 | 122 |
|
91 |
| - equal($('.ui-page-active .ui-content .ui-listview li').text(), "Sub Item 10Sub Item 11Sub Item 12", 'Text should be "Sub Item 10Sub Item 11Sub Item 12"'); |
92 |
| - start(); |
93 |
| - }, 500); |
| 123 | + function(){ |
| 124 | + $('.ui-page-active li:eq(2) a:eq(0)').click(); |
| 125 | + |
| 126 | + equal($('.ui-page-active .ui-content .ui-listview li').text(), "Sub Item 10Sub Item 11Sub Item 12", 'Text should be "Sub Item 10Sub Item 11Sub Item 12"'); |
| 127 | + start(); |
| 128 | + } |
| 129 | + ]); |
94 | 130 | });
|
95 | 131 |
|
96 | 132 | module('Ordered Lists');
|
97 | 133 |
|
98 | 134 | asyncTest( "changes to the numbered list page and enhances it", function() {
|
99 |
| - location.href = location.href.split('#')[0] + "#numbered-list-test"; |
100 |
| - setTimeout(function() { |
101 |
| - var $new_page = $('#numbered-list-test'); |
102 |
| - ok($new_page.hasClass('ui-page-active'), "Makes the new page active when the hash is changed."); |
103 |
| - ok($('.ui-link-inherit', $new_page).first().text() == "Number 1", "The text of the first LI should be Number 1"); |
104 |
| - start(); |
105 |
| - }, 1000); |
| 135 | + $.testHelper.pageSequence([ |
| 136 | + function(){ |
| 137 | + $.testHelper.openPage("#numbered-list-test"); |
| 138 | + }, |
| 139 | + |
| 140 | + function(){ |
| 141 | + var $new_page = $('#numbered-list-test'); |
| 142 | + ok($new_page.hasClass('ui-page-active'), "Makes the new page active when the hash is changed."); |
| 143 | + ok($('.ui-link-inherit', $new_page).first().text() == "Number 1", "The text of the first LI should be Number 1"); |
| 144 | + start(); |
| 145 | + } |
| 146 | + ]); |
106 | 147 | });
|
107 | 148 |
|
108 | 149 | asyncTest( "changes to number 1 page when the li a is clicked", function() {
|
109 |
| - $('#numbered-list-test li a').first().click(); |
110 |
| - setTimeout(function() { |
111 |
| - ok($('#numbered-list-results').hasClass('ui-page-active'), "The new numbered page was transitioned correctly."); |
112 |
| - start(); |
113 |
| - }, 1000); |
| 150 | + $.testHelper.pageSequence([ |
| 151 | + function(){ |
| 152 | + $('#numbered-list-test li a').first().click(); |
| 153 | + }, |
| 154 | + |
| 155 | + function(){ |
| 156 | + ok($('#numbered-list-results').hasClass('ui-page-active'), "The new numbered page was transitioned correctly."); |
| 157 | + start(); |
| 158 | + } |
| 159 | + ]); |
114 | 160 | });
|
115 | 161 |
|
116 | 162 | asyncTest( "takes us back to the numbered list when the back button is clicked", function() {
|
117 |
| - $.testHelper.openPage('#numbered-list-test') |
118 |
| - $.testHelper.openPage('#numbered-list-results') |
119 |
| - window.history.back(); |
120 |
| - setTimeout(function() { |
121 |
| - ok($('#numbered-list-test').hasClass('ui-page-active')); |
122 |
| - start(); |
123 |
| - }, 1000); |
| 163 | + $.testHelper.pageSequence([ |
| 164 | + function(){ |
| 165 | + $.testHelper.openPage('#numbered-list-test') |
| 166 | + }, |
| 167 | + |
| 168 | + function(){ |
| 169 | + $.testHelper.openPage('#numbered-list-results') |
| 170 | + }, |
| 171 | + |
| 172 | + function(){ |
| 173 | + window.history.back(); |
| 174 | + }, |
| 175 | + |
| 176 | + function(){ |
| 177 | + ok($('#numbered-list-test').hasClass('ui-page-active')); |
| 178 | + start(); |
| 179 | + } |
| 180 | + ]); |
124 | 181 | });
|
125 | 182 |
|
126 | 183 | module('Read only list');
|
127 | 184 |
|
128 | 185 | asyncTest( "changes to the read only page when hash is changed", function() {
|
129 |
| - location.href = location.href.split('#')[0] + "#read-only-list-test"; |
130 |
| - setTimeout(function() { |
131 |
| - var $new_page = $('#read-only-list-test'); |
132 |
| - ok($new_page.hasClass('ui-page-active'), "makes the read only page the active page"); |
133 |
| - ok($('li', $new_page).first().text() === "Read", "The first LI has the proper text."); |
134 |
| - start(); |
135 |
| - }, 1000); |
| 186 | + $.testHelper.pageSequence([ |
| 187 | + function(){ |
| 188 | + $.testHelper.openPage("#read-only-list-test") |
| 189 | + }, |
| 190 | + |
| 191 | + function(){ |
| 192 | + var $new_page = $('#read-only-list-test'); |
| 193 | + ok($new_page.hasClass('ui-page-active'), "makes the read only page the active page"); |
| 194 | + ok($('li', $new_page).first().text() === "Read", "The first LI has the proper text."); |
| 195 | + start(); |
| 196 | + } |
| 197 | + ]); |
136 | 198 | });
|
137 | 199 |
|
138 | 200 | module('Split view list');
|
139 | 201 |
|
140 | 202 | asyncTest( "changes the page to the split view list and enhances it correctly.", function() {
|
141 |
| - $.testHelper.openPage("#split-list-test"); |
| 203 | + $.testHelper.pageSequence([ |
| 204 | + function(){ |
| 205 | + $.testHelper.openPage("#split-list-test"); |
| 206 | + }, |
142 | 207 |
|
143 |
| - setTimeout(function() { |
144 |
| - var $new_page = $('#split-list-test'); |
145 |
| - ok($('.ui-li-link-alt', $new_page).length == 3); |
146 |
| - ok($('.ui-link-inherit', $new_page).length == 3); |
147 |
| - start(); |
148 |
| - }, 1000); |
| 208 | + function(){ |
| 209 | + var $new_page = $('#split-list-test'); |
| 210 | + ok($('.ui-li-link-alt', $new_page).length == 3); |
| 211 | + ok($('.ui-link-inherit', $new_page).length == 3); |
| 212 | + start(); |
| 213 | + } |
| 214 | + ]); |
149 | 215 | });
|
150 | 216 |
|
151 | 217 | asyncTest( "change the page to the split view page 1 when the first link is clicked", function() {
|
152 |
| - $.testHelper.openPage("#split-list-test"); |
| 218 | + $.testHelper.pageSequence([ |
| 219 | + function(){ |
| 220 | + $.testHelper.openPage("#split-list-test"); |
| 221 | + }, |
153 | 222 |
|
154 |
| - setTimeout(function(){ |
155 |
| - $('.ui-page-active .ui-li a:eq(0)').click(); |
156 |
| - }, 500); |
| 223 | + function(){ |
| 224 | + $('.ui-page-active .ui-li a:eq(0)').click(); |
| 225 | + }, |
157 | 226 |
|
158 |
| - setTimeout(function() { |
159 |
| - ok($('#split-list-link1').hasClass('ui-page-active')); |
160 |
| - start(); |
161 |
| - }, 1000); |
| 227 | + function(){ |
| 228 | + ok($('#split-list-link1').hasClass('ui-page-active')); |
| 229 | + start(); |
| 230 | + } |
| 231 | + ]); |
162 | 232 | });
|
163 | 233 |
|
164 | 234 | asyncTest( "Slide back to the parent list view when the back button is clicked", function() {
|
165 |
| - $.testHelper.openPage("#split-list-test"); |
| 235 | + $.testHelper.pageSequence([ |
| 236 | + function(){ |
| 237 | + $.testHelper.openPage("#split-list-test"); |
| 238 | + }, |
166 | 239 |
|
167 |
| - $.testHelper.sequence([ |
168 | 240 | function(){
|
169 | 241 | $('.ui-page-active .ui-listview a:eq(0)').click();
|
170 | 242 | },
|
|
173 | 245 | history.back();
|
174 | 246 | },
|
175 | 247 |
|
176 |
| - function() { |
| 248 | + function(){ |
177 | 249 | ok($('#split-list-test').hasClass('ui-page-active'));
|
178 | 250 | start();
|
179 | 251 | }
|
180 |
| - ], 1000); |
| 252 | + ]); |
181 | 253 | });
|
182 | 254 |
|
183 | 255 | asyncTest( "Clicking on the icon (the second link) should take the user to other a href of this LI", function() {
|
184 |
| - $.testHelper.openPage("#split-list-test"); |
| 256 | + $.testHelper.pageSequence([ |
| 257 | + function(){ |
| 258 | + $.testHelper.openPage("#split-list-test"); |
| 259 | + }, |
185 | 260 |
|
186 |
| - setTimeout(function(){ |
187 |
| - $('.ui-page-active .ui-li-link-alt:eq(0)').click(); |
188 |
| - }, 500); |
| 261 | + function(){ |
| 262 | + $('.ui-page-active .ui-li-link-alt:eq(0)').click(); |
| 263 | + }, |
189 | 264 |
|
190 |
| - setTimeout(function() { |
191 |
| - ok($('#split-list-link2').hasClass('ui-page-active')); |
192 |
| - start(); |
193 |
| - }, 1000); |
| 265 | + function(){ |
| 266 | + ok($('#split-list-link2').hasClass('ui-page-active')); |
| 267 | + start(); |
| 268 | + } |
| 269 | + ]); |
194 | 270 | });
|
195 | 271 |
|
196 | 272 | module( "List Dividers" );
|
197 | 273 |
|
198 | 274 | asyncTest( "Makes the list divider page the active page and enhances it correctly.", function() {
|
199 |
| - location.href = location.href.split('#')[0] + "#list-divider-test"; |
200 |
| - setTimeout(function() { |
201 |
| - var $new_page = $('#list-divider-test'); |
202 |
| - ok($new_page.find('.ui-li-divider').length == 2); |
203 |
| - ok($new_page.hasClass('ui-page-active')); |
204 |
| - start(); |
205 |
| - }, 1000); |
| 275 | + $.testHelper.pageSequence([ |
| 276 | + function(){ |
| 277 | + $.testHelper.openPage("#list-divider-test"); |
| 278 | + }, |
| 279 | + |
| 280 | + function(){ |
| 281 | + var $new_page = $('#list-divider-test'); |
| 282 | + ok($new_page.find('.ui-li-divider').length == 2); |
| 283 | + ok($new_page.hasClass('ui-page-active')); |
| 284 | + start(); |
| 285 | + } |
| 286 | + ]); |
206 | 287 | });
|
207 | 288 |
|
208 | 289 | module( "Search Filter");
|
|
0 commit comments