/[projects]/misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/1_dom/_zero_config.js
ViewVC logotype

Contents of /misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/1_dom/_zero_config.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, 3 months ago) by torben
File MIME type: application/javascript
File size: 13331 byte(s)
initial import
1 // DATA_TEMPLATE: dom_data
2 oTest.fnStart( "Sanity checks for DataTables with DOM data" );
3
4 oTest.fnTest(
5 "jQuery.dataTable function",
6 null,
7 function () { return typeof jQuery().dataTable == "function"; }
8 );
9
10 oTest.fnTest(
11 "jQuery.dataTableSettings storage array",
12 null,
13 function () { return typeof jQuery().dataTableSettings == "object"; }
14 );
15
16 oTest.fnTest(
17 "jQuery.dataTableExt plugin object",
18 null,
19 function () { return typeof jQuery().dataTableExt == "object"; }
20 );
21
22 $(document).ready( function () {
23 $('#example').dataTable();
24
25 /* Basic checks */
26 oTest.fnTest(
27 "Length changing div exists",
28 null,
29 function () { return document.getElementById('example_length') != null; }
30 );
31
32 oTest.fnTest(
33 "Filtering div exists",
34 null,
35 function () { return document.getElementById('example_filter') != null; }
36 );
37
38 oTest.fnTest(
39 "Information div exists",
40 null,
41 function () { return document.getElementById('example_info') != null; }
42 );
43
44 oTest.fnTest(
45 "Pagination div exists",
46 null,
47 function () { return document.getElementById('example_paginate') != null; }
48 );
49
50 oTest.fnTest(
51 "Processing div is off by default",
52 null,
53 function () { return document.getElementById('example_processing') == null; }
54 );
55
56 oTest.fnTest(
57 "10 rows shown on the first page",
58 null,
59 function () { return $('#example tbody tr').length == 10; }
60 );
61
62 oTest.fnTest(
63 "Initial sort occured",
64 null,
65 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
66 );
67
68 /* Need to use the WaitTest for sorting due to the setTimeout datatables uses */
69 oTest.fnTest(
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"; }
73 );
74
75 oTest.fnTest(
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"; }
79 );
80
81 oTest.fnTest(
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"; }
85 );
86
87 oTest.fnTest(
88 "Sorting (first click) on numeric column",
89 function () { $('#example thead th:eq(3)').click(); },
90 function () { return $('#example tbody td:eq(3)').html() == "-"; }
91 );
92
93 oTest.fnTest(
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"; }
97 );
98
99 oTest.fnTest(
100 "Sorting multi-column (first click)",
101 function () {
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; }
107 );
108
109 oTest.fnTest(
110 "Sorting multi-column - sorting second column only",
111 function () {
112 $('#example thead th:eq(1)').click(); },
113 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
114 );
115
116 /* Basic paging */
117 oTest.fnTest(
118 "Paging to second page",
119 function () { $('#example_next').click(); },
120 function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; }
121 );
122
123 oTest.fnTest(
124 "Paging to first page",
125 function () { $('#example_previous').click(); },
126 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
127 );
128
129 oTest.fnTest(
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"; }
133 );
134
135 /* Changing length */
136 oTest.fnTest(
137 "Changing table length to 25 records",
138 function () { $("select[name=example_length]").val('25').change(); },
139 function () { return $('#example tbody tr').length == 25; }
140 );
141
142 oTest.fnTest(
143 "Changing table length to 50 records",
144 function () { $("select[name=example_length]").val('50').change(); },
145 function () { return $('#example tbody tr').length == 50; }
146 );
147
148 oTest.fnTest(
149 "Changing table length to 100 records",
150 function () { $("select[name=example_length]").val('100').change(); },
151 function () { return $('#example tbody tr').length == 57; }
152 );
153
154 oTest.fnTest(
155 "Changing table length to 10 records",
156 function () { $("select[name=example_length]").val('10').change(); },
157 function () { return $('#example tbody tr').length == 10; }
158 );
159
160 /*
161 * Information element
162 */
163 oTest.fnTest(
164 "Information on zero config",
165 null,
166 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
167 );
168
169 oTest.fnTest(
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"; }
173 );
174
175 oTest.fnTest(
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"; }
179 );
180
181 oTest.fnTest(
182 "Information on last page",
183 function () {
184 $('#example_next').click();
185 $('#example_next').click();
186 $('#example_next').click();
187 },
188 function () { return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; }
189 );
190
191 oTest.fnTest(
192 "Information back on first page",
193 function () {
194 $('#example_previous').click();
195 $('#example_previous').click();
196 $('#example_previous').click();
197 $('#example_previous').click();
198 $('#example_previous').click();
199 },
200 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
201 );
202
203 oTest.fnTest(
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"; }
207 );
208
209 oTest.fnTest(
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"; }
213 );
214
215 oTest.fnTest(
216 "Information with 100 records - first page",
217 function () {
218 $('#example_previous').click();
219 $("select[name=example_length]").val('100').change();
220 },
221 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 57 of 57 entries"; }
222 );
223
224 oTest.fnTest(
225 "Information back to 10 records",
226 function () {
227 $('#example_previous').click();
228 $("select[name=example_length]").val('10').change();
229 },
230 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
231 );
232
233 oTest.fnTest(
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)"; }
238 );
239
240 oTest.fnTest(
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)"; }
245 );
246
247 oTest.fnTest(
248 "Information with filter 'Win' last page",
249 function () {
250 $('#example_next').click();
251 $('#example_next').click();
252 },
253 function () { return document.getElementById('example_info').innerHTML ==
254 "Showing 31 to 31 of 31 entries (filtered from 57 total entries)"; }
255 );
256
257 oTest.fnTest(
258 "Information with filter 'Win' back to first page",
259 function () {
260 $('#example_previous').click();
261 $('#example_previous').click();
262 $('#example_previous').click();
263 },
264 function () { return document.getElementById('example_info').innerHTML ==
265 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
266 );
267
268 oTest.fnTest(
269 "Information with filter 'Win' second page - second time",
270 function () {
271 $('#example_next').click();
272 },
273 function () { return document.getElementById('example_info').innerHTML ==
274 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
275 );
276
277 oTest.fnTest(
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)"; }
282 );
283
284 oTest.fnTest(
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)"; }
289 );
290
291 oTest.fnTest(
292 "Information with filter 'Win' second page - third time",
293 function () {
294 $('#example_next').click();
295 },
296 function () { return document.getElementById('example_info').innerHTML ==
297 "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
298 );
299
300 oTest.fnTest(
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"; }
305 );
306
307
308 /*
309 * Filtering
310 */
311 oTest.fnTest(
312 "Filter 'W' - rows",
313 function () {
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"; }
319 );
320
321 oTest.fnTest(
322 "Filter 'W' - info",
323 null,
324 function () { return document.getElementById('example_info').innerHTML ==
325 "Showing 1 to 10 of 42 entries (filtered from 57 total entries)"; }
326 );
327
328 oTest.fnTest(
329 "Filter 'Wi'",
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)"; }
333 );
334
335 oTest.fnTest(
336 "Filter 'Win'",
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)"; }
340 );
341
342 oTest.fnTest(
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)"; }
346 );
347
348 oTest.fnTest(
349 "Filter 'Win' - sorting column 1 info",
350 null,
351 function () { return document.getElementById('example_info').innerHTML ==
352 "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
353 );
354
355 oTest.fnTest(
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"; }
359 );
360
361 oTest.fnTest(
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"; }
365 );
366
367 oTest.fnTest(
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"; }
371 );
372
373 oTest.fnTest(
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"; }
377 );
378
379 oTest.fnTest(
380 "Filter 'Win' - sorting col 3 - reversed info",
381 null,
382 function () { return document.getElementById('example_info').innerHTML ==
383 "Showing 1 to 6 of 6 entries (filtered from 57 total entries)"; }
384 );
385
386 oTest.fnTest(
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"; }
391 );
392
393 oTest.fnTest(
394 "Filter 'nothinghere' - info",
395 null,
396 function () { return document.getElementById('example_info').innerHTML ==
397 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
398 );
399
400 oTest.fnTest(
401 "Filter back to blank and 1st column sorting",
402 function () {
403 $('#example_filter input').val("").keyup();
404 $('#example thead th:eq(0)').click();
405 },
406 function () { return document.getElementById('example_info').innerHTML ==
407 "Showing 1 to 10 of 57 entries"; }
408 );
409
410 oTest.fnTest(
411 "Prefixing a filter entry",
412 function () {
413 $('#example_filter input').val("Win").keyup();
414 $('#example_filter input').val("GeckoWin").keyup();
415 },
416 function () { return document.getElementById('example_info').innerHTML ==
417 "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
418 );
419
420 oTest.fnTest(
421 "Prefixing a filter entry with space",
422 function () {
423 $('#example_filter input').val("Gecko Win").keyup();
424 },
425 function () { return document.getElementById('example_info').innerHTML ==
426 "Showing 1 to 10 of 17 entries (filtered from 57 total entries)"; }
427 );
428
429
430
431
432
433
434
435
436 oTest.fnComplete();
437 } );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20