1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "Sanity checks for DataTables with data from JS - Object data source" );
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 () {
25 { "mDataProp": "engine" },
26 { "mDataProp": "browser" },
27 { "mDataProp": "platform" },
28 { "mDataProp": "version" },
29 { "mDataProp": "grade" }
34 "browser": "Internet Explorer 4.0",
35 "platform": "Win 95+",
41 "browser": "Internet Explorer 5.0",
42 "platform": "Win 95+",
48 "browser": "Internet Explorer 5.5",
49 "platform": "Win 95+",
55 "browser": "Internet Explorer 6",
56 "platform": "Win 98+",
62 "browser": "Internet Explorer 7",
63 "platform": "Win XP SP2+",
69 "browser": "AOL browser (AOL desktop)",
76 "browser": "Firefox 1.0",
77 "platform": "Win 98+ / OSX.2+",
83 "browser": "Firefox 1.5",
84 "platform": "Win 98+ / OSX.2+",
90 "browser": "Firefox 2.0",
91 "platform": "Win 98+ / OSX.2+",
97 "browser": "Firefox 3.0",
98 "platform": "Win 2k+ / OSX.3+",
104 "browser": "Camino 1.0",
105 "platform": "OSX.2+",
111 "browser": "Camino 1.5",
112 "platform": "OSX.3+",
118 "browser": "Netscape 7.2",
119 "platform": "Win 95+ / Mac OS 8.6-9.2",
125 "browser": "Netscape Browser 8",
126 "platform": "Win 98SE+",
132 "browser": "Netscape Navigator 9",
133 "platform": "Win 98+ / OSX.2+",
139 "browser": "Mozilla 1.0",
140 "platform": "Win 95+ / OSX.1+",
146 "browser": "Mozilla 1.1",
147 "platform": "Win 95+ / OSX.1+",
153 "browser": "Mozilla 1.2",
154 "platform": "Win 95+ / OSX.1+",
160 "browser": "Mozilla 1.3",
161 "platform": "Win 95+ / OSX.1+",
167 "browser": "Mozilla 1.4",
168 "platform": "Win 95+ / OSX.1+",
174 "browser": "Mozilla 1.5",
175 "platform": "Win 95+ / OSX.1+",
181 "browser": "Mozilla 1.6",
182 "platform": "Win 95+ / OSX.1+",
188 "browser": "Mozilla 1.7",
189 "platform": "Win 98+ / OSX.1+",
195 "browser": "Mozilla 1.8",
196 "platform": "Win 98+ / OSX.1+",
202 "browser": "Seamonkey 1.1",
203 "platform": "Win 98+ / OSX.2+",
209 "browser": "Epiphany 2.20",
216 "browser": "Safari 1.2",
223 "browser": "Safari 1.3",
230 "browser": "Safari 2.0",
231 "platform": "OSX.4+",
237 "browser": "Safari 3.0",
238 "platform": "OSX.4+",
244 "browser": "OmniWeb 5.5",
245 "platform": "OSX.4+",
251 "browser": "iPod Touch / iPhone",
265 "browser": "Opera 7.0",
266 "platform": "Win 95+ / OSX.1+",
272 "browser": "Opera 7.5",
273 "platform": "Win 95+ / OSX.2+",
279 "browser": "Opera 8.0",
280 "platform": "Win 95+ / OSX.2+",
286 "browser": "Opera 8.5",
287 "platform": "Win 95+ / OSX.2+",
293 "browser": "Opera 9.0",
294 "platform": "Win 95+ / OSX.3+",
300 "browser": "Opera 9.2",
301 "platform": "Win 88+ / OSX.3+",
307 "browser": "Opera 9.5",
308 "platform": "Win 88+ / OSX.3+",
314 "browser": "Opera for Wii",
321 "browser": "Nokia N800",
328 "browser": "Nintendo DS browser",
329 "platform": "Nintendo DS",
331 "grade": "C/A<sup>1</sup>"
335 "browser": "Konqureror 3.1",
336 "platform": "KDE 3.1",
342 "browser": "Konqureror 3.3",
343 "platform": "KDE 3.3",
349 "browser": "Konqureror 3.5",
350 "platform": "KDE 3.5",
356 "browser": "Internet Explorer 4.5",
357 "platform": "Mac OS 8-9",
363 "browser": "Internet Explorer 5.1",
364 "platform": "Mac OS 7.6-9",
370 "browser": "Internet Explorer 5.2",
371 "platform": "Mac OS 8-X",
377 "browser": "NetFront 3.1",
378 "platform": "Embedded devices",
384 "browser": "NetFront 3.4",
385 "platform": "Embedded devices",
391 "browser": "Dillo 0.8",
392 "platform": "Embedded devices",
399 "platform": "Text only",
406 "platform": "Text only",
412 "browser": "IE Mobile",
413 "platform": "Windows Mobile 6",
419 "browser": "PSP browser",
425 "engine": "Other browsers",
426 "browser": "All others",
433 $('#example').dataTable( oInit );
437 "Length changing div exists",
439 function () { return document.getElementById('example_length') != null; }
443 "Filtering div exists",
445 function () { return document.getElementById('example_filter') != null; }
449 "Information div exists",
451 function () { return document.getElementById('example_info') != null; }
455 "Pagination div exists",
457 function () { return document.getElementById('example_paginate') != null; }
461 "Processing div is off by default",
463 function () { return document.getElementById('example_processing') == null; }
467 "10 rows shown on the first page",
469 function () { return $('#example tbody tr').length == 10; }
473 "Initial sort occured",
475 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
478 /* Need to use the WaitTest for sorting due to the setTimeout datatables uses */
480 "Sorting (first click) on second column",
481 function () { $('#example thead th:eq(1)').click(); },
482 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
486 "Sorting (second click) on second column",
487 function () { $('#example thead th:eq(1)').click(); },
488 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
492 "Sorting (third click) on second column",
493 function () { $('#example thead th:eq(1)').click(); },
494 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
498 "Sorting (first click) on numeric column",
499 function () { $('#example thead th:eq(3)').click(); },
500 function () { return $('#example tbody td:eq(3)').html() == "-"; }
504 "Sorting (second click) on numeric column",
505 function () { $('#example thead th:eq(3)').click(); },
506 function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
510 "Sorting multi-column (first click)",
512 $('#example thead th:eq(0)').click();
513 oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); },
514 function () { var b =
515 $('#example tbody td:eq(0)').html() == "Gecko" &&
516 $('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; }
520 "Sorting multi-column - sorting second column only",
522 $('#example thead th:eq(1)').click(); },
523 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
528 "Paging to second page",
529 function () { $('#example_next').click(); },
530 function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; }
534 "Paging to first page",
535 function () { $('#example_previous').click(); },
536 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
540 "Attempting to page back beyond the first page",
541 function () { $('#example_previous').click(); },
542 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
545 /* Changing length */
547 "Changing table length to 25 records",
548 function () { $("select[name=example_length]").val('25').change(); },
549 function () { return $('#example tbody tr').length == 25; }
553 "Changing table length to 50 records",
554 function () { $("select[name=example_length]").val('50').change(); },
555 function () { return $('#example tbody tr').length == 50; }
559 "Changing table length to 100 records",
560 function () { $("select[name=example_length]").val('100').change(); },
561 function () { return $('#example tbody tr').length == 57; }
565 "Changing table length to 10 records",
566 function () { $("select[name=example_length]").val('10').change(); },
567 function () { return $('#example tbody tr').length == 10; }
571 * Information element
574 "Information on zero config",
576 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
580 "Information on second page",
581 function () { $('#example_next').click(); },
582 function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; }
586 "Information on third page",
587 function () { $('#example_next').click(); },
588 function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; }
592 "Information on last page",
594 $('#example_next').click();
595 $('#example_next').click();
596 $('#example_next').click();
598 function () { return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; }
602 "Information back on first page",
604 $('#example_previous').click();
605 $('#example_previous').click();
606 $('#example_previous').click();
607 $('#example_previous').click();
608 $('#example_previous').click();
610 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
614 "Information with 25 records",
615 function () { $("select[name=example_length]").val('25').change(); },
616 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 25 of 57 entries"; }
620 "Information with 25 records - second page",
621 function () { $('#example_next').click(); },
622 function () { return document.getElementById('example_info').innerHTML == "Showing 26 to 50 of 57 entries"; }
626 "Information with 100 records - first page",
628 $('#example_previous').click();
629 $("select[name=example_length]").val('100').change();
631 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 57 of 57 entries"; }
635 "Information back to 10 records",
637 $('#example_previous').click();
638 $("select[name=example_length]").val('10').change();
640 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
644 "Information with filter 'Win'",
645 function () { $('#example_filter input').val("Win").keyup(); },
646 function () { return document.getElementById('example_info').innerHTML ==
647 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
651 "Information with filter 'Win' second page",
652 function () { $('#example_next').click(); },
653 function () { return document.getElementById('example_info').innerHTML ==
654 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
658 "Information with filter 'Win' last page",
660 $('#example_next').click();
661 $('#example_next').click();
663 function () { return document.getElementById('example_info').innerHTML ==
664 "Showing 31 to 31 of 31 entries (filtered from 57 total entries)"; }
668 "Information with filter 'Win' back to first page",
670 $('#example_previous').click();
671 $('#example_previous').click();
672 $('#example_previous').click();
674 function () { return document.getElementById('example_info').innerHTML ==
675 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
679 "Information with filter 'Win' second page - second time",
681 $('#example_next').click();
683 function () { return document.getElementById('example_info').innerHTML ==
684 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
688 "Information with filter increased to 'Win 98'",
689 function () { $('#example_filter input').val("Win 98").keyup(); },
690 function () { return document.getElementById('example_info').innerHTML ==
691 "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; }
695 "Information with filter decreased to 'Win'",
696 function () { $('#example_filter input').val("Win").keyup(); },
697 function () { return document.getElementById('example_info').innerHTML ==
698 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
702 "Information with filter 'Win' second page - third time",
704 $('#example_next').click();
706 function () { return document.getElementById('example_info').innerHTML ==
707 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
711 "Information with filter removed",
712 function () { $('#example_filter input').val("").keyup(); },
713 function () { return document.getElementById('example_info').innerHTML ==
714 "Showing 1 to 10 of 57 entries"; }
724 /* Reset the table such that the old sorting doesn't mess things up */
725 oSession.fnRestore();
726 $('#example').dataTable( oInit );
727 $('#example_filter input').val("W").keyup(); },
728 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; }
734 function () { return document.getElementById('example_info').innerHTML ==
735 "Showing 1 to 10 of 42 entries (filtered from 57 total entries)"; }
740 function () { $('#example_filter input').val("Wi").keyup(); },
741 function () { return document.getElementById('example_info').innerHTML ==
742 "Showing 1 to 10 of 32 entries (filtered from 57 total entries)"; }
747 function () { $('#example_filter input').val("Win").keyup(); },
748 function () { return document.getElementById('example_info').innerHTML ==
749 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
753 "Filter 'Win' - sorting column 1",
754 function () { $('#example thead th:eq(1)').click(); },
755 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "AOL browser (AOL desktop)"; }
759 "Filter 'Win' - sorting column 1 info",
761 function () { return document.getElementById('example_info').innerHTML ==
762 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
766 "Filter 'Win' - sorting column 1 reverse",
767 function () { $('#example thead th:eq(1)').click(); },
768 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Seamonkey 1.1"; }
772 "Filter 'Win XP' - maintaing reverse sorting col 1",
773 function () { $('#example_filter input').val("Win XP").keyup(); },
774 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Internet Explorer 7"; }
778 "Filter 'Win XP' - sorting col 3",
779 function () { $('#example thead th:eq(3)').click(); },
780 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "4"; }
784 "Filter 'Win XP' - sorting col 3 - reversed",
785 function () { $('#example thead th:eq(3)').click(); },
786 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "7"; }
790 "Filter 'Win' - sorting col 3 - reversed info",
792 function () { return document.getElementById('example_info').innerHTML ==
793 "Showing 1 to 6 of 6 entries (filtered from 57 total entries)"; }
797 "Filter 'nothinghere'",
798 function () { $('#example_filter input').val("nothinghere").keyup(); },
799 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() ==
800 "No matching records found"; }
804 "Filter 'nothinghere' - info",
806 function () { return document.getElementById('example_info').innerHTML ==
807 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
811 "Filter back to blank and 1st column sorting",
813 $('#example_filter input').val("").keyup();
814 $('#example thead th:eq(0)').click();
816 function () { return document.getElementById('example_info').innerHTML ==
817 "Showing 1 to 10 of 57 entries"; }
821 "Prefixing a filter entry",
823 $('#example_filter input').val("Win").keyup();
824 $('#example_filter input').val("GeckoWin").keyup();
826 function () { return document.getElementById('example_info').innerHTML ==
827 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
831 "Prefixing a filter entry with space",
833 $('#example_filter input').val("Gecko Win").keyup();
835 function () { return document.getElementById('example_info').innerHTML ==
836 "Showing 1 to 10 of 17 entries (filtered from 57 total entries)"; }