Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit 5e87e84

Browse files
committed
Did a sweep over all tests (except for filter tests) to convert them to pageSequence() where possible. This fixes the test bustages caused by the changePage() refactoring. Note that the "Multiple nested lists on a page" test is still busted, as it is on the HEAD.
1 parent 786ef25 commit 5e87e84

File tree

1 file changed

+185
-104
lines changed

1 file changed

+185
-104
lines changed

tests/unit/listview/listview_core.js

Lines changed: 185 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
// TODO split out into seperate test files
66
(function($){
7+
78
$.mobile.defaultTransition = "none";
89
module('Basic Linked list', {
910
setup: function(){
@@ -19,152 +20,223 @@
1920
});
2021

2122
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+
},
2327

24-
setTimeout(function(){
25-
$('#basic-linked-test li a').first().click();
26-
}, 500);
28+
function(){
29+
$('#basic-linked-test li a').first().click();
30+
},
2731

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+
]);
3237
});
3338

3439
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+
},
3644

37-
window.history.back();
45+
function(){
46+
window.history.back();
47+
},
3848

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+
]);
4354
});
4455

4556
module('Nested List Test');
4657

4758
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+
]);
5571
});
5672

5773
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")');
6274

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+
]);
6893
});
6994

7095
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+
},
73100

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+
]);
78110
});
79111

80112
test( "nested list title should use first text node, regardless of line breaks", function(){
81113
ok($('#nested-list-test .linebreaknode').text() === "More animals", 'Text should be "More animals"');
82114
});
83115

84116
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+
},
90122

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+
]);
94130
});
95131

96132
module('Ordered Lists');
97133

98134
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+
]);
106147
});
107148

108149
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+
]);
114160
});
115161

116162
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+
]);
124181
});
125182

126183
module('Read only list');
127184

128185
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+
]);
136198
});
137199

138200
module('Split view list');
139201

140202
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+
},
142207

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+
]);
149215
});
150216

151217
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+
},
153222

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+
},
157226

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+
]);
162232
});
163233

164234
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+
},
166239

167-
$.testHelper.sequence([
168240
function(){
169241
$('.ui-page-active .ui-listview a:eq(0)').click();
170242
},
@@ -173,36 +245,45 @@
173245
history.back();
174246
},
175247

176-
function() {
248+
function(){
177249
ok($('#split-list-test').hasClass('ui-page-active'));
178250
start();
179251
}
180-
], 1000);
252+
]);
181253
});
182254

183255
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+
},
185260

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+
},
189264

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+
]);
194270
});
195271

196272
module( "List Dividers" );
197273

198274
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+
]);
206287
});
207288

208289
module( "Search Filter");

0 commit comments

Comments
 (0)