annotate DataTables-1.9.4/media/unit_testing/tests_onhold/6_delayed_rendering/sAjaxDataProp.js @ 0:ac5f9272033b draft

first upload
author saskia-hiltemann
date Tue, 01 Jul 2014 11:42:23 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
1 // DATA_TEMPLATE: empty_table
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
2 oTest.fnStart( "Custom data source property - property given" );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
3
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
4
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
5 $(document).ready( function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
6 var oInit = {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
7 "sAjaxSource": "../../../examples/ajax/sources/custom_prop.txt",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
8 "bDeferRender": true,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
9 "sAjaxDataProp": "demo"
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
10 };
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
11 $('#example').dataTable( oInit );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
12
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
13 oTest.fnWaitTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
14 "10 rows shown on the first page",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
15 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
16 function () { return $('#example tbody tr').length == 10; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
17 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
18
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
19 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
20 "Initial sort occured",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
21 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
22 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
23 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
24
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
25 /* Need to use the WaitTest for sorting due to the setTimeout datatables uses */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
26 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
27 "Sorting (first click) on second column",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
28 function () { $('#example thead th:eq(1)').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
29 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
30 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
31
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
32 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
33 "Sorting (second click) on second column",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
34 function () { $('#example thead th:eq(1)').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
35 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
36 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
37
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
38 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
39 "Sorting (third click) on second column",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
40 function () { $('#example thead th:eq(1)').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
41 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
42 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
43
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
44 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
45 "Sorting (first click) on numeric column",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
46 function () { $('#example thead th:eq(3)').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
47 function () { return $('#example tbody td:eq(3)').html() == "-"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
48 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
49
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
50 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
51 "Sorting (second click) on numeric column",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
52 function () { $('#example thead th:eq(3)').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
53 function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
54 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
55
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
56 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
57 "Sorting multi-column (first click)",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
58 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
59 $('#example thead th:eq(0)').click();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
60 oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
61 function () { var b =
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
62 $('#example tbody td:eq(0)').html() == "Gecko" &&
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
63 $('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
64 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
65
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
66 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
67 "Sorting multi-column - sorting second column only",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
68 function () {
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
69 $('#example thead th:eq(1)').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
70 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
71 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
72
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
73 /* Basic paging */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
74 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
75 "Paging to second page",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
76 function () { $('#example_next').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
77 function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
78 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
79
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
80 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
81 "Paging to first page",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
82 function () { $('#example_previous').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
83 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
84 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
85
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
86 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
87 "Attempting to page back beyond the first page",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
88 function () { $('#example_previous').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
89 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
90 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
91
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
92 /* Changing length */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
93 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
94 "Changing table length to 25 records",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
95 function () { $("select[name=example_length]").val('25').change(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
96 function () { return $('#example tbody tr').length == 25; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
97 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
98
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
99 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
100 "Changing table length to 50 records",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
101 function () { $("select[name=example_length]").val('50').change(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
102 function () { return $('#example tbody tr').length == 50; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
103 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
104
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
105 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
106 "Changing table length to 100 records",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
107 function () { $("select[name=example_length]").val('100').change(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
108 function () { return $('#example tbody tr').length == 57; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
109 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
110
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
111 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
112 "Changing table length to 10 records",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
113 function () { $("select[name=example_length]").val('10').change(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
114 function () { return $('#example tbody tr').length == 10; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
115 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
116
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
117 /*
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
118 * Information element
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
119 */
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
120 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
121 "Information on zero config",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
122 null,
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
123 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
124 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
125
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
126 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
127 "Information on second page",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
128 function () { $('#example_next').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
129 function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
130 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
131
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
132 oTest.fnTest(
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
133 "Information on third page",
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
134 function () { $('#example_next').click(); },
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
135 function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; }
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
136 );
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
137
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
138
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
139 oTest.fnComplete();
ac5f9272033b first upload
saskia-hiltemann
parents:
diff changeset
140 } );