Mercurial > repos > saskia-hiltemann > ireport
comparison DataTables-1.9.4/media/unit_testing/tests_onhold/6_delayed_rendering/_zero_config.js @ 0:ac5f9272033b draft
first upload
author | saskia-hiltemann |
---|---|
date | Tue, 01 Jul 2014 11:42:23 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ac5f9272033b |
---|---|
1 // DATA_TEMPLATE: empty_table | |
2 oTest.fnStart( "Sanity checks for DataTables with delayed DOM creation" ); | |
3 | |
4 $(document).ready( function () { | |
5 var oInit = { | |
6 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt", | |
7 "bDeferRender": true | |
8 }; | |
9 $('#example').dataTable( oInit ); | |
10 | |
11 oTest.fnWaitTest( | |
12 "10 rows shown on the first page", | |
13 null, | |
14 function () { return $('#example tbody tr').length == 10; } | |
15 ); | |
16 | |
17 oTest.fnWaitTest( | |
18 "10 TR elements available from fnGetNodes", | |
19 null, | |
20 function () { return $('#example').dataTable().fnGetNodes().length == 10; } | |
21 ); | |
22 | |
23 oTest.fnTest( | |
24 "Initial sort occured", | |
25 null, | |
26 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; } | |
27 ); | |
28 | |
29 oTest.fnTest( | |
30 "Sorting (first click) on second column", | |
31 function () { $('#example thead th:eq(1)').click(); }, | |
32 function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
33 ); | |
34 | |
35 oTest.fnWaitTest( | |
36 "14 TR elements available from fnGetNodes after sort", | |
37 null, | |
38 function () { return $('#example').dataTable().fnGetNodes().length == 14; } | |
39 ); | |
40 | |
41 oTest.fnTest( | |
42 "Sorting (second click) on second column", | |
43 function () { $('#example thead th:eq(1)').click(); }, | |
44 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; } | |
45 ); | |
46 | |
47 oTest.fnTest( | |
48 "Sorting (third click) on second column", | |
49 function () { $('#example thead th:eq(1)').click(); }, | |
50 function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
51 ); | |
52 | |
53 oTest.fnTest( | |
54 "Sorting (first click) on numeric column", | |
55 function () { $('#example thead th:eq(3)').click(); }, | |
56 function () { return $('#example tbody td:eq(3)').html() == "-"; } | |
57 ); | |
58 | |
59 oTest.fnTest( | |
60 "Sorting (second click) on numeric column", | |
61 function () { $('#example thead th:eq(3)').click(); }, | |
62 function () { return $('#example tbody td:eq(3)').html() == "522.1"; } | |
63 ); | |
64 | |
65 oTest.fnTest( | |
66 "Sorting multi-column (first click)", | |
67 function () { | |
68 $('#example thead th:eq(0)').click(); | |
69 oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); }, | |
70 function () { var b = | |
71 $('#example tbody td:eq(0)').html() == "Gecko" && | |
72 $('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; } | |
73 ); | |
74 | |
75 oTest.fnTest( | |
76 "Sorting multi-column - sorting second column only", | |
77 function () { | |
78 $('#example thead th:eq(1)').click(); }, | |
79 function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
80 ); | |
81 | |
82 /* Basic paging */ | |
83 oTest.fnTest( | |
84 "Paging to second page", | |
85 function () { $('#example_next').click(); }, | |
86 function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; } | |
87 ); | |
88 | |
89 oTest.fnTest( | |
90 "Paging to first page", | |
91 function () { $('#example_previous').click(); }, | |
92 function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
93 ); | |
94 | |
95 oTest.fnTest( | |
96 "Attempting to page back beyond the first page", | |
97 function () { $('#example_previous').click(); }, | |
98 function () { return $('#example tbody td:eq(1)').html() == "All others"; } | |
99 ); | |
100 | |
101 /* Changing length */ | |
102 oTest.fnTest( | |
103 "Changing table length to 25 records", | |
104 function () { $("select[name=example_length]").val('25').change(); }, | |
105 function () { return $('#example tbody tr').length == 25; } | |
106 ); | |
107 | |
108 oTest.fnTest( | |
109 "Changing table length to 50 records", | |
110 function () { $("select[name=example_length]").val('50').change(); }, | |
111 function () { return $('#example tbody tr').length == 50; } | |
112 ); | |
113 | |
114 oTest.fnTest( | |
115 "Changing table length to 100 records", | |
116 function () { $("select[name=example_length]").val('100').change(); }, | |
117 function () { return $('#example tbody tr').length == 57; } | |
118 ); | |
119 | |
120 oTest.fnTest( | |
121 "Changing table length to 10 records", | |
122 function () { $("select[name=example_length]").val('10').change(); }, | |
123 function () { return $('#example tbody tr').length == 10; } | |
124 ); | |
125 | |
126 /* | |
127 * Information element | |
128 */ | |
129 oTest.fnTest( | |
130 "Information on zero config", | |
131 null, | |
132 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
133 ); | |
134 | |
135 oTest.fnTest( | |
136 "Information on second page", | |
137 function () { $('#example_next').click(); }, | |
138 function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; } | |
139 ); | |
140 | |
141 oTest.fnTest( | |
142 "Information on third page", | |
143 function () { $('#example_next').click(); }, | |
144 function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; } | |
145 ); | |
146 | |
147 oTest.fnTest( | |
148 "Information on last page", | |
149 function () { | |
150 $('#example_next').click(); | |
151 $('#example_next').click(); | |
152 $('#example_next').click(); | |
153 }, | |
154 function () { return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; } | |
155 ); | |
156 | |
157 oTest.fnTest( | |
158 "Information back on first page", | |
159 function () { | |
160 $('#example_previous').click(); | |
161 $('#example_previous').click(); | |
162 $('#example_previous').click(); | |
163 $('#example_previous').click(); | |
164 $('#example_previous').click(); | |
165 }, | |
166 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
167 ); | |
168 | |
169 oTest.fnTest( | |
170 "Information with 25 records", | |
171 function () { $("select[name=example_length]").val('25').change(); }, | |
172 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 25 of 57 entries"; } | |
173 ); | |
174 | |
175 oTest.fnTest( | |
176 "Information with 25 records - second page", | |
177 function () { $('#example_next').click(); }, | |
178 function () { return document.getElementById('example_info').innerHTML == "Showing 26 to 50 of 57 entries"; } | |
179 ); | |
180 | |
181 oTest.fnTest( | |
182 "Information with 100 records - first page", | |
183 function () { | |
184 $('#example_previous').click(); | |
185 $("select[name=example_length]").val('100').change(); | |
186 }, | |
187 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 57 of 57 entries"; } | |
188 ); | |
189 | |
190 oTest.fnTest( | |
191 "Information back to 10 records", | |
192 function () { | |
193 $('#example_previous').click(); | |
194 $("select[name=example_length]").val('10').change(); | |
195 }, | |
196 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; } | |
197 ); | |
198 | |
199 oTest.fnTest( | |
200 "Information with filter 'Win'", | |
201 function () { $('#example_filter input').val("Win").keyup(); }, | |
202 function () { return document.getElementById('example_info').innerHTML == | |
203 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
204 ); | |
205 | |
206 oTest.fnTest( | |
207 "Information with filter 'Win' second page", | |
208 function () { $('#example_next').click(); }, | |
209 function () { return document.getElementById('example_info').innerHTML == | |
210 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
211 ); | |
212 | |
213 oTest.fnTest( | |
214 "Information with filter 'Win' last page", | |
215 function () { | |
216 $('#example_next').click(); | |
217 $('#example_next').click(); | |
218 }, | |
219 function () { return document.getElementById('example_info').innerHTML == | |
220 "Showing 31 to 31 of 31 entries (filtered from 57 total entries)"; } | |
221 ); | |
222 | |
223 oTest.fnTest( | |
224 "Information with filter 'Win' back to first page", | |
225 function () { | |
226 $('#example_previous').click(); | |
227 $('#example_previous').click(); | |
228 $('#example_previous').click(); | |
229 }, | |
230 function () { return document.getElementById('example_info').innerHTML == | |
231 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
232 ); | |
233 | |
234 oTest.fnTest( | |
235 "Information with filter 'Win' second page - second time", | |
236 function () { | |
237 $('#example_next').click(); | |
238 }, | |
239 function () { return document.getElementById('example_info').innerHTML == | |
240 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
241 ); | |
242 | |
243 oTest.fnTest( | |
244 "Information with filter increased to 'Win 98'", | |
245 function () { $('#example_filter input').val("Win 98").keyup(); }, | |
246 function () { return document.getElementById('example_info').innerHTML == | |
247 "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; } | |
248 ); | |
249 | |
250 oTest.fnTest( | |
251 "Information with filter decreased to 'Win'", | |
252 function () { $('#example_filter input').val("Win").keyup(); }, | |
253 function () { return document.getElementById('example_info').innerHTML == | |
254 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
255 ); | |
256 | |
257 oTest.fnTest( | |
258 "Information with filter 'Win' second page - third time", | |
259 function () { | |
260 $('#example_next').click(); | |
261 }, | |
262 function () { return document.getElementById('example_info').innerHTML == | |
263 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; } | |
264 ); | |
265 | |
266 oTest.fnTest( | |
267 "Information with filter removed", | |
268 function () { $('#example_filter input').val("").keyup(); }, | |
269 function () { return document.getElementById('example_info').innerHTML == | |
270 "Showing 1 to 10 of 57 entries"; } | |
271 ); | |
272 | |
273 | |
274 /* | |
275 * Filtering | |
276 */ | |
277 oTest.fnWaitTest( | |
278 "Filter 'W' - rows", | |
279 function () { | |
280 /* Reset the table such that the old sorting doesn't mess things up */ | |
281 oSession.fnRestore(); | |
282 $('#example').dataTable( oInit ); | |
283 $('#example_filter input').val("W").keyup(); }, | |
284 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; } | |
285 ); | |
286 | |
287 oTest.fnTest( | |
288 "Filter 'W' - info", | |
289 null, | |
290 function () { return document.getElementById('example_info').innerHTML == | |
291 "Showing 1 to 10 of 42 entries (filtered from 57 total entries)"; } | |
292 ); | |
293 | |
294 oTest.fnTest( | |
295 "Filter 'Wi'", | |
296 function () { $('#example_filter input').val("Wi").keyup(); }, | |
297 function () { return document.getElementById('example_info').innerHTML == | |
298 "Showing 1 to 10 of 32 entries (filtered from 57 total entries)"; } | |
299 ); | |
300 | |
301 oTest.fnTest( | |
302 "Filter 'Win'", | |
303 function () { $('#example_filter input').val("Win").keyup(); }, | |
304 function () { return document.getElementById('example_info').innerHTML == | |
305 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
306 ); | |
307 | |
308 oTest.fnTest( | |
309 "Filter 'Win' - sorting column 1", | |
310 function () { $('#example thead th:eq(1)').click(); }, | |
311 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "AOL browser (AOL desktop)"; } | |
312 ); | |
313 | |
314 oTest.fnTest( | |
315 "Filter 'Win' - sorting column 1 info", | |
316 null, | |
317 function () { return document.getElementById('example_info').innerHTML == | |
318 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; } | |
319 ); | |
320 | |
321 oTest.fnTest( | |
322 "Filter 'Win' - sorting column 1 reverse", | |
323 function () { $('#example thead th:eq(1)').click(); }, | |
324 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Seamonkey 1.1"; } | |
325 ); | |
326 | |
327 oTest.fnTest( | |
328 "Filter 'Win XP' - maintaing reverse sorting col 1", | |
329 function () { $('#example_filter input').val("Win XP").keyup(); }, | |
330 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Internet Explorer 7"; } | |
331 ); | |
332 | |
333 oTest.fnTest( | |
334 "Filter 'Win XP' - sorting col 3", | |
335 function () { $('#example thead th:eq(3)').click(); }, | |
336 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "4"; } | |
337 ); | |
338 | |
339 oTest.fnTest( | |
340 "Filter 'Win XP' - sorting col 3 - reversed", | |
341 function () { $('#example thead th:eq(3)').click(); }, | |
342 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "7"; } | |
343 ); | |
344 | |
345 oTest.fnTest( | |
346 "Filter 'Win' - sorting col 3 - reversed info", | |
347 null, | |
348 function () { return document.getElementById('example_info').innerHTML == | |
349 "Showing 1 to 6 of 6 entries (filtered from 57 total entries)"; } | |
350 ); | |
351 | |
352 oTest.fnTest( | |
353 "Filter 'nothinghere'", | |
354 function () { $('#example_filter input').val("nothinghere").keyup(); }, | |
355 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == | |
356 "No matching records found"; } | |
357 ); | |
358 | |
359 oTest.fnTest( | |
360 "Filter 'nothinghere' - info", | |
361 null, | |
362 function () { return document.getElementById('example_info').innerHTML == | |
363 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; } | |
364 ); | |
365 | |
366 oTest.fnTest( | |
367 "Filter back to blank and 1st column sorting", | |
368 function () { | |
369 $('#example_filter input').val("").keyup(); | |
370 $('#example thead th:eq(0)').click(); | |
371 }, | |
372 function () { return document.getElementById('example_info').innerHTML == | |
373 "Showing 1 to 10 of 57 entries"; } | |
374 ); | |
375 | |
376 oTest.fnTest( | |
377 "Prefixing a filter entry", | |
378 function () { | |
379 $('#example_filter input').val("Win").keyup(); | |
380 $('#example_filter input').val("GeckoWin").keyup(); | |
381 }, | |
382 function () { return document.getElementById('example_info').innerHTML == | |
383 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; } | |
384 ); | |
385 | |
386 oTest.fnTest( | |
387 "Prefixing a filter entry with space", | |
388 function () { | |
389 $('#example_filter input').val("Gecko Win").keyup(); | |
390 }, | |
391 function () { return document.getElementById('example_info').innerHTML == | |
392 "Showing 1 to 10 of 17 entries (filtered from 57 total entries)"; } | |
393 ); | |
394 | |
395 | |
396 | |
397 | |
398 | |
399 | |
400 | |
401 | |
402 oTest.fnComplete(); | |
403 } ); |