1 // DATA_TEMPLATE: dom_data_th
2 oTest.fnStart( "Sanity checks for DataTables with DOM data and a TH in the body" );
5 "jQuery.dataTable function",
7 function () { return typeof jQuery().dataTable == "function"; }
11 "jQuery.dataTableSettings storage array",
13 function () { return typeof jQuery().dataTableSettings == "object"; }
17 "jQuery.dataTableExt plugin object",
19 function () { return typeof jQuery().dataTableExt == "object"; }
22 $(document).ready( function () {
23 $('#example').dataTable();
27 "Length changing div exists",
29 function () { return document.getElementById('example_length') != null; }
33 "Filtering div exists",
35 function () { return document.getElementById('example_filter') != null; }
39 "Information div exists",
41 function () { return document.getElementById('example_info') != null; }
45 "Pagination div exists",
47 function () { return document.getElementById('example_paginate') != null; }
51 "Processing div is off by default",
53 function () { return document.getElementById('example_processing') == null; }
57 "10 rows shown on the first page",
59 function () { return $('#example tbody tr').length == 10; }
63 "Initial sort occured",
65 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
68 /* Need to use the WaitTest for sorting due to the setTimeout datatables uses */
70 "Sorting (first click) on second column",
71 function () { $('#example thead th:eq(1)').click(); },
72 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
76 "Sorting (second click) on second column",
77 function () { $('#example thead th:eq(1)').click(); },
78 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
82 "Sorting (third click) on second column",
83 function () { $('#example thead th:eq(1)').click(); },
84 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
88 "Sorting (first click) on numeric column",
89 function () { $('#example thead th:eq(3)').click(); },
90 function () { return $('#example tbody td:eq(3)').html() == "-"; }
94 "Sorting (second click) on numeric column",
95 function () { $('#example thead th:eq(3)').click(); },
96 function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
100 "Sorting multi-column (first click)",
102 $('#example thead th:eq(0)').click();
103 oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); },
104 function () { var b =
105 $('#example tbody td:eq(0)').html() == "Gecko" &&
106 $('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; }
110 "Sorting multi-column - sorting second column only",
112 $('#example thead th:eq(1)').click(); },
113 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
118 "Paging to second page",
119 function () { $('#example_next').click(); },
120 function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; }
124 "Paging to first page",
125 function () { $('#example_previous').click(); },
126 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
130 "Attempting to page back beyond the first page",
131 function () { $('#example_previous').click(); },
132 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
135 /* Changing length */
137 "Changing table length to 25 records",
138 function () { $("select[name=example_length]").val('25').change(); },
139 function () { return $('#example tbody tr').length == 25; }
143 "Changing table length to 50 records",
144 function () { $("select[name=example_length]").val('50').change(); },
145 function () { return $('#example tbody tr').length == 50; }
149 "Changing table length to 100 records",
150 function () { $("select[name=example_length]").val('100').change(); },
151 function () { return $('#example tbody tr').length == 57; }
155 "Changing table length to 10 records",
156 function () { $("select[name=example_length]").val('10').change(); },
157 function () { return $('#example tbody tr').length == 10; }
161 * Information element
164 "Information on zero config",
166 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
170 "Information on second page",
171 function () { $('#example_next').click(); },
172 function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; }
176 "Information on third page",
177 function () { $('#example_next').click(); },
178 function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; }
182 "Information on last page",
184 $('#example_next').click();
185 $('#example_next').click();
186 $('#example_next').click();
188 function () { return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; }
192 "Information back on first page",
194 $('#example_previous').click();
195 $('#example_previous').click();
196 $('#example_previous').click();
197 $('#example_previous').click();
198 $('#example_previous').click();
200 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
204 "Information with 25 records",
205 function () { $("select[name=example_length]").val('25').change(); },
206 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 25 of 57 entries"; }
210 "Information with 25 records - second page",
211 function () { $('#example_next').click(); },
212 function () { return document.getElementById('example_info').innerHTML == "Showing 26 to 50 of 57 entries"; }
216 "Information with 100 records - first page",
218 $('#example_previous').click();
219 $("select[name=example_length]").val('100').change();
221 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 57 of 57 entries"; }
225 "Information back to 10 records",
227 $('#example_previous').click();
228 $("select[name=example_length]").val('10').change();
230 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
234 "Information with filter 'Win'",
235 function () { $('#example_filter input').val("Win").keyup(); },
236 function () { return document.getElementById('example_info').innerHTML ==
237 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
241 "Information with filter 'Win' second page",
242 function () { $('#example_next').click(); },
243 function () { return document.getElementById('example_info').innerHTML ==
244 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
248 "Information with filter 'Win' last page",
250 $('#example_next').click();
251 $('#example_next').click();
253 function () { return document.getElementById('example_info').innerHTML ==
254 "Showing 31 to 31 of 31 entries (filtered from 57 total entries)"; }
258 "Information with filter 'Win' back to first page",
260 $('#example_previous').click();
261 $('#example_previous').click();
262 $('#example_previous').click();
264 function () { return document.getElementById('example_info').innerHTML ==
265 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
269 "Information with filter 'Win' second page - second time",
271 $('#example_next').click();
273 function () { return document.getElementById('example_info').innerHTML ==
274 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
278 "Information with filter increased to 'Win 98'",
279 function () { $('#example_filter input').val("Win 98").keyup(); },
280 function () { return document.getElementById('example_info').innerHTML ==
281 "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; }
285 "Information with filter decreased to 'Win'",
286 function () { $('#example_filter input').val("Win").keyup(); },
287 function () { return document.getElementById('example_info').innerHTML ==
288 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
292 "Information with filter 'Win' second page - third time",
294 $('#example_next').click();
296 function () { return document.getElementById('example_info').innerHTML ==
297 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
301 "Information with filter removed",
302 function () { $('#example_filter input').val("").keyup(); },
303 function () { return document.getElementById('example_info').innerHTML ==
304 "Showing 1 to 10 of 57 entries"; }
314 /* Reset the table such that the old sorting doesn't mess things up */
315 oSession.fnRestore();
316 $('#example').dataTable();
317 $('#example_filter input').val("W").keyup(); },
318 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; }
324 function () { return document.getElementById('example_info').innerHTML ==
325 "Showing 1 to 10 of 42 entries (filtered from 57 total entries)"; }
330 function () { $('#example_filter input').val("Wi").keyup(); },
331 function () { return document.getElementById('example_info').innerHTML ==
332 "Showing 1 to 10 of 32 entries (filtered from 57 total entries)"; }
337 function () { $('#example_filter input').val("Win").keyup(); },
338 function () { return document.getElementById('example_info').innerHTML ==
339 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
343 "Filter 'Win' - sorting column 1",
344 function () { $('#example thead th:eq(1)').click(); },
345 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "AOL browser (AOL desktop)"; }
349 "Filter 'Win' - sorting column 1 info",
351 function () { return document.getElementById('example_info').innerHTML ==
352 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
356 "Filter 'Win' - sorting column 1 reverse",
357 function () { $('#example thead th:eq(1)').click(); },
358 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Seamonkey 1.1"; }
362 "Filter 'Win XP' - maintaing reverse sorting col 1",
363 function () { $('#example_filter input').val("Win XP").keyup(); },
364 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Internet Explorer 7"; }
368 "Filter 'Win XP' - sorting col 3",
369 function () { $('#example thead th:eq(3)').click(); },
370 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "4"; }
374 "Filter 'Win XP' - sorting col 3 - reversed",
375 function () { $('#example thead th:eq(3)').click(); },
376 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "7"; }
380 "Filter 'Win' - sorting col 3 - reversed info",
382 function () { return document.getElementById('example_info').innerHTML ==
383 "Showing 1 to 6 of 6 entries (filtered from 57 total entries)"; }
387 "Filter 'nothinghere'",
388 function () { $('#example_filter input').val("nothinghere").keyup(); },
389 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() ==
390 "No matching records found"; }
394 "Filter 'nothinghere' - info",
396 function () { return document.getElementById('example_info').innerHTML ==
397 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
401 "Filter back to blank and 1st column sorting",
403 $('#example_filter input').val("").keyup();
404 $('#example thead th:eq(0)').click();
406 function () { return document.getElementById('example_info').innerHTML ==
407 "Showing 1 to 10 of 57 entries"; }
411 "Prefixing a filter entry",
413 $('#example_filter input').val("Win").keyup();
414 $('#example_filter input').val("GeckoWin").keyup();
416 function () { return document.getElementById('example_info').innerHTML ==
417 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
421 "Prefixing a filter entry with space",
423 $('#example_filter input').val("Gecko Win").keyup();
425 function () { return document.getElementById('example_info').innerHTML ==
426 "Showing 1 to 10 of 17 entries (filtered from 57 total entries)"; }