/[projects]/misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/4_server-side/sAjaxDataProp.js
ViewVC logotype

Contents of /misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/4_server-side/sAjaxDataProp.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2125 - (show annotations) (download) (as text)
Wed Mar 12 19:30:05 2014 UTC (10 years, 2 months ago) by torben
File MIME type: application/javascript
File size: 4671 byte(s)
initial import
1 // DATA_TEMPLATE: empty_table
2 /*
3 * NOTE: There are some differences in this zero config script for server-side
4 * processing compared to the other data sources. The main reason for this is the
5 * difference in how the server-side processing does it's filtering. Also the
6 * sorting state is always reset on each draw.
7 */
8 oTest.fnStart( "Custom data property in returned Ajax" );
9
10 $(document).ready( function () {
11 $('#example').dataTable( {
12 "bServerSide": true,
13 "sAjaxSource": "../../../examples/server_side/scripts/custom_data_property.php",
14 "sAjaxDataProp": "test"
15 } );
16
17 oTest.fnWaitTest(
18 "10 rows shown on the first page",
19 null,
20 function () { return $('#example tbody tr').length == 10; }
21 );
22
23 oTest.fnWaitTest(
24 "Initial sort occured",
25 null,
26 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
27 );
28
29 /* Need to use the WaitTest for sorting due to the setTimeout datatables uses */
30 oTest.fnWaitTest(
31 "Sorting (first click) on second column",
32 function () { $('#example thead th:eq(1)').click(); },
33 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
34 );
35
36 oTest.fnWaitTest(
37 "Sorting (second click) on second column",
38 function () { $('#example thead th:eq(1)').click(); },
39 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
40 );
41
42 oTest.fnWaitTest(
43 "Sorting (third click) on second column",
44 function () { $('#example thead th:eq(1)').click(); },
45 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
46 );
47
48 oTest.fnWaitTest(
49 "Sorting (first click) on numeric column",
50 function () { $('#example thead th:eq(3)').click(); },
51 function () { return $('#example tbody td:eq(3)').html() == "-"; }
52 );
53
54 oTest.fnWaitTest(
55 "Sorting (second click) on numeric column",
56 function () { $('#example thead th:eq(3)').click(); },
57 function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
58 );
59
60 oTest.fnWaitTest(
61 "Sorting multi-column (first click)",
62 function () {
63 $('#example thead th:eq(0)').click();
64 oDispacher.click( $('#example thead th:eq(1)')[0], { 'shift': true } ); },
65 function () { var b =
66 $('#example tbody td:eq(0)').html() == "Gecko" &&
67 $('#example tbody td:eq(1)').html() == "Camino 1.0"; return b; }
68 );
69
70 oTest.fnWaitTest(
71 "Sorting multi-column - sorting first column only",
72 function () {
73 $('#example thead th:eq(0)').click(); },
74 function () { var b =
75 $('#example tbody td:eq(0)').html() == "Gecko" &&
76 $('#example tbody td:eq(1)').html() == "Firefox 1.0"; return b; }
77 );
78
79 /* Basic paging */
80 oTest.fnWaitTest(
81 "Paging to second page",
82 function () { $('#example_next').click(); },
83 function () { return $('#example tbody td:eq(1)').html() == "Mozilla 1.1"; }
84 );
85
86 oTest.fnWaitTest(
87 "Paging to first page",
88 function () { $('#example_previous').click(); },
89 function () { return $('#example tbody td:eq(1)').html() == "Firefox 1.0"; }
90 );
91
92 oTest.fnWaitTest(
93 "Attempting to page back beyond the first page",
94 function () { $('#example_previous').click(); },
95 function () { return $('#example tbody td:eq(1)').html() == "Firefox 1.0"; }
96 );
97
98 /* Changing length */
99 oTest.fnWaitTest(
100 "Changing table length to 25 records",
101 function () { $("select[name=example_length]").val('25').change(); },
102 function () { return $('#example tbody tr').length == 25; }
103 );
104
105 oTest.fnWaitTest(
106 "Changing table length to 50 records",
107 function () { $("select[name=example_length]").val('50').change(); },
108 function () { return $('#example tbody tr').length == 50; }
109 );
110
111 oTest.fnWaitTest(
112 "Changing table length to 100 records",
113 function () { $("select[name=example_length]").val('100').change(); },
114 function () { return $('#example tbody tr').length == 57; }
115 );
116
117 oTest.fnWaitTest(
118 "Changing table length to 10 records",
119 function () { $("select[name=example_length]").val('10').change(); },
120 function () { return $('#example tbody tr').length == 10; }
121 );
122
123 /*
124 * Information element
125 */
126 oTest.fnWaitTest(
127 "Information on zero config",
128 null,
129 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
130 );
131
132 oTest.fnWaitTest(
133 "Information on second page",
134 function () { $('#example_next').click(); },
135 function () { return document.getElementById('example_info').innerHTML == "Showing 11 to 20 of 57 entries"; }
136 );
137
138 oTest.fnWaitTest(
139 "Information on third page",
140 function () { $('#example_next').click(); },
141 function () { return document.getElementById('example_info').innerHTML == "Showing 21 to 30 of 57 entries"; }
142 );
143
144
145 oTest.fnComplete();
146 } );

  ViewVC Help
Powered by ViewVC 1.1.20