1 // DATA_TEMPLATE: js_data
2 oTest.fnStart( "Sanity checks for DataTables with data from JS - Null data source for last column" );
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 () {
33 $('#example').dataTable( oInit );
37 "Length changing div exists",
39 function () { return document.getElementById('example_length') != null; }
43 "Filtering div exists",
45 function () { return document.getElementById('example_filter') != null; }
49 "Information div exists",
51 function () { return document.getElementById('example_info') != null; }
55 "Pagination div exists",
57 function () { return document.getElementById('example_paginate') != null; }
61 "Processing div is off by default",
63 function () { return document.getElementById('example_processing') == null; }
67 "10 rows shown on the first page",
69 function () { return $('#example tbody tr').length == 10; }
73 "Initial sort occured",
75 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
78 /* Need to use the WaitTest for sorting due to the setTimeout datatables uses */
80 "Data in last column is empty",
82 function () { return $('#example tbody td:eq(4)').html() == ""; }
86 "Sorting (first click) on second column",
87 function () { $('#example thead th:eq(1)').click(); },
88 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
91 "Data in last column is still empty",
93 function () { return $('#example tbody td:eq(4)').html() == ""; }
97 "Sorting (second click) on second column",
98 function () { $('#example thead th:eq(1)').click(); },
99 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
103 "Sorting (third click) on second column",
104 function () { $('#example thead th:eq(1)').click(); },
105 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
109 "Sorting (first click) on numeric column",
110 function () { $('#example thead th:eq(3)').click(); },
111 function () { return $('#example tbody td:eq(3)').html() == "-"; }
115 "Sorting (second click) on numeric column",
116 function () { $('#example thead th:eq(3)').click(); },
117 function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
121 "Sorting multi-column (first click)",
123 $('#example thead th:eq(0)').click();
124 oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); },
125 function () { var b =
126 $('#example tbody td:eq(0)').html() == "Gecko" &&
127 $('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; }
131 "Sorting multi-column - sorting second column only",
133 $('#example thead th:eq(1)').click(); },
134 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
139 "Paging to second page",
140 function () { $('#example_next').click(); },
141 function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; }
145 "Paging to first page",
146 function () { $('#example_previous').click(); },
147 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
151 "Attempting to page back beyond the first page",
152 function () { $('#example_previous').click(); },
153 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
156 /* Changing length */
158 "Changing table length to 25 records",
159 function () { $("select[name=example_length]").val('25').change(); },
160 function () { return $('#example tbody tr').length == 25; }
164 "Changing table length to 50 records",
165 function () { $("select[name=example_length]").val('50').change(); },
166 function () { return $('#example tbody tr').length == 50; }
170 "Changing table length to 100 records",
171 function () { $("select[name=example_length]").val('100').change(); },
172 function () { return $('#example tbody tr').length == 57; }
176 "Changing table length to 10 records",
177 function () { $("select[name=example_length]").val('10').change(); },
178 function () { return $('#example tbody tr').length == 10; }
182 * Information element
185 "Information on zero config",
187 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
191 "Information on second page",
192 function () { $('#example_next').click(); },
193 function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; }
197 "Information on third page",
198 function () { $('#example_next').click(); },
199 function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; }
203 "Information on last page",
205 $('#example_next').click();
206 $('#example_next').click();
207 $('#example_next').click();
209 function () { return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; }
213 "Information back on first page",
215 $('#example_previous').click();
216 $('#example_previous').click();
217 $('#example_previous').click();
218 $('#example_previous').click();
219 $('#example_previous').click();
221 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
225 "Information with 25 records",
226 function () { $("select[name=example_length]").val('25').change(); },
227 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 25 of 57 entries"; }
231 "Information with 25 records - second page",
232 function () { $('#example_next').click(); },
233 function () { return document.getElementById('example_info').innerHTML == "Showing 26 to 50 of 57 entries"; }
237 "Information with 100 records - first page",
239 $('#example_previous').click();
240 $("select[name=example_length]").val('100').change();
242 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 57 of 57 entries"; }
246 "Information back to 10 records",
248 $('#example_previous').click();
249 $("select[name=example_length]").val('10').change();
251 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
255 "Information with filter 'Win'",
256 function () { $('#example_filter input').val("Win").keyup(); },
257 function () { return document.getElementById('example_info').innerHTML ==
258 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
262 "Information with filter 'Win' second page",
263 function () { $('#example_next').click(); },
264 function () { return document.getElementById('example_info').innerHTML ==
265 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
269 "Information with filter 'Win' last page",
271 $('#example_next').click();
272 $('#example_next').click();
274 function () { return document.getElementById('example_info').innerHTML ==
275 "Showing 31 to 31 of 31 entries (filtered from 57 total entries)"; }
279 "Information with filter 'Win' back to first page",
281 $('#example_previous').click();
282 $('#example_previous').click();
283 $('#example_previous').click();
285 function () { return document.getElementById('example_info').innerHTML ==
286 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
290 "Information with filter 'Win' second page - second time",
292 $('#example_next').click();
294 function () { return document.getElementById('example_info').innerHTML ==
295 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
299 "Information with filter increased to 'Win 98'",
300 function () { $('#example_filter input').val("Win 98").keyup(); },
301 function () { return document.getElementById('example_info').innerHTML ==
302 "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; }
306 "Information with filter decreased to 'Win'",
307 function () { $('#example_filter input').val("Win").keyup(); },
308 function () { return document.getElementById('example_info').innerHTML ==
309 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
313 "Information with filter 'Win' second page - third time",
315 $('#example_next').click();
317 function () { return document.getElementById('example_info').innerHTML ==
318 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
322 "Information with filter removed",
323 function () { $('#example_filter input').val("").keyup(); },
324 function () { return document.getElementById('example_info').innerHTML ==
325 "Showing 1 to 10 of 57 entries"; }
335 /* Reset the table such that the old sorting doesn't mess things up */
336 oSession.fnRestore();
337 $('#example').dataTable( oInit );
338 $('#example_filter input').val("W").keyup(); },
339 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; }
345 function () { return document.getElementById('example_info').innerHTML ==
346 "Showing 1 to 10 of 42 entries (filtered from 57 total entries)"; }
351 function () { $('#example_filter input').val("Wi").keyup(); },
352 function () { return document.getElementById('example_info').innerHTML ==
353 "Showing 1 to 10 of 32 entries (filtered from 57 total entries)"; }
358 function () { $('#example_filter input').val("Win").keyup(); },
359 function () { return document.getElementById('example_info').innerHTML ==
360 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
364 "Filter 'Win' - sorting column 1",
365 function () { $('#example thead th:eq(1)').click(); },
366 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "AOL browser (AOL desktop)"; }
370 "Filter 'Win' - sorting column 1 info",
372 function () { return document.getElementById('example_info').innerHTML ==
373 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
377 "Filter 'Win' - sorting column 1 reverse",
378 function () { $('#example thead th:eq(1)').click(); },
379 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Seamonkey 1.1"; }
383 "Filter 'Win XP' - maintaing reverse sorting col 1",
384 function () { $('#example_filter input').val("Win XP").keyup(); },
385 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Internet Explorer 7"; }
389 "Filter 'Win XP' - sorting col 3",
390 function () { $('#example thead th:eq(3)').click(); },
391 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "4"; }
395 "Filter 'Win XP' - sorting col 3 - reversed",
396 function () { $('#example thead th:eq(3)').click(); },
397 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "7"; }
401 "Filter 'Win' - sorting col 3 - reversed info",
403 function () { return document.getElementById('example_info').innerHTML ==
404 "Showing 1 to 6 of 6 entries (filtered from 57 total entries)"; }
408 "Filter 'nothinghere'",
409 function () { $('#example_filter input').val("nothinghere").keyup(); },
410 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() ==
411 "No matching records found"; }
415 "Filter 'nothinghere' - info",
417 function () { return document.getElementById('example_info').innerHTML ==
418 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
422 "Filter back to blank and 1st column sorting",
424 $('#example_filter input').val("").keyup();
425 $('#example thead th:eq(0)').click();
427 function () { return document.getElementById('example_info').innerHTML ==
428 "Showing 1 to 10 of 57 entries"; }
432 "Prefixing a filter entry",
434 $('#example_filter input').val("Win").keyup();
435 $('#example_filter input').val("GeckoWin").keyup();
437 function () { return document.getElementById('example_info').innerHTML ==
438 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
442 "Prefixing a filter entry with space",
444 $('#example_filter input').val("Gecko Win").keyup();
446 function () { return document.getElementById('example_info').innerHTML ==
447 "Showing 1 to 10 of 17 entries (filtered from 57 total entries)"; }