Add datatables-1.9.4 and jquery-1.10.2 libraries
[proteocache.git] / webapp / resources / datatables-1.9.4 / media / unit_testing / tests_onhold / 5_ajax_objects / _zero_config_null_source.js
1 // DATA_TEMPLATE: js_data
2 oTest.fnStart( "Sanity checks for DataTables with data from JS - Null data source for last column" );
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         var oInit = {
24                 "aoColumns": [
25                         null,
26                         null,
27                         null,
28                         null,
29                         { "mData": null }
30                 ],
31                 "aaData": gaaData
32         };
33         $('#example').dataTable( oInit );
34         
35         /* Basic checks */
36         oTest.fnWaitTest( 
37                 "Length changing div exists",
38                 null,
39                 function () { return document.getElementById('example_length') != null; }
40         );
41         
42         oTest.fnTest( 
43                 "Filtering div exists",
44                 null,
45                 function () { return document.getElementById('example_filter') != null; }
46         );
47         
48         oTest.fnTest( 
49                 "Information div exists",
50                 null,
51                 function () { return document.getElementById('example_info') != null; }
52         );
53         
54         oTest.fnTest( 
55                 "Pagination div exists",
56                 null,
57                 function () { return document.getElementById('example_paginate') != null; }
58         );
59         
60         oTest.fnTest( 
61                 "Processing div is off by default",
62                 null,
63                 function () { return document.getElementById('example_processing') == null; }
64         );
65         
66         oTest.fnWaitTest( 
67                 "10 rows shown on the first page",
68                 null,
69                 function () { return $('#example tbody tr').length == 10; }
70         );
71         
72         oTest.fnTest( 
73                 "Initial sort occured",
74                 null,
75                 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
76         );
77         
78         /* Need to use the WaitTest for sorting due to the setTimeout datatables uses */
79         oTest.fnTest( 
80                 "Data in last column is empty",
81                 null,
82                 function () { return $('#example tbody td:eq(4)').html() == ""; }
83         );
84         
85         oTest.fnTest( 
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"; }
89         );
90         oTest.fnTest( 
91                 "Data in last column is still empty",
92                 null,
93                 function () { return $('#example tbody td:eq(4)').html() == ""; }
94         );
95         
96         oTest.fnTest( 
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"; }
100         );
101         
102         oTest.fnTest( 
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"; }
106         );
107         
108         oTest.fnTest( 
109                 "Sorting (first click) on numeric column",
110                 function () { $('#example thead th:eq(3)').click(); },
111                 function () { return $('#example tbody td:eq(3)').html() == "-"; }
112         );
113         
114         oTest.fnTest( 
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"; }
118         );
119         
120         oTest.fnTest( 
121                 "Sorting multi-column (first click)",
122                 function () { 
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; }
128         );
129         
130         oTest.fnTest( 
131                 "Sorting multi-column - sorting second column only",
132                 function () { 
133                         $('#example thead th:eq(1)').click(); },
134                 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
135         );
136         
137         /* Basic paging */
138         oTest.fnTest( 
139                 "Paging to second page",
140                 function () { $('#example_next').click(); },
141                 function () { return $('#example tbody td:eq(1)').html() == "IE Mobile"; }
142         );
143         
144         oTest.fnTest( 
145                 "Paging to first page",
146                 function () { $('#example_previous').click(); },
147                 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
148         );
149         
150         oTest.fnTest( 
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"; }
154         );
155         
156         /* Changing length */
157         oTest.fnTest( 
158                 "Changing table length to 25 records",
159                 function () { $("select[name=example_length]").val('25').change(); },
160                 function () { return $('#example tbody tr').length == 25; }
161         );
162         
163         oTest.fnTest( 
164                 "Changing table length to 50 records",
165                 function () { $("select[name=example_length]").val('50').change(); },
166                 function () { return $('#example tbody tr').length == 50; }
167         );
168         
169         oTest.fnTest( 
170                 "Changing table length to 100 records",
171                 function () { $("select[name=example_length]").val('100').change(); },
172                 function () { return $('#example tbody tr').length == 57; }
173         );
174         
175         oTest.fnTest( 
176                 "Changing table length to 10 records",
177                 function () { $("select[name=example_length]").val('10').change(); },
178                 function () { return $('#example tbody tr').length == 10; }
179         );
180         
181         /*
182          * Information element
183          */
184         oTest.fnTest(
185                 "Information on zero config",
186                 null,
187                 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
188         );
189         
190         oTest.fnTest(
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"; }
194         );
195         
196         oTest.fnTest(
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"; }
200         );
201         
202         oTest.fnTest(
203                 "Information on last page",
204                 function () {
205                         $('#example_next').click();
206                         $('#example_next').click();
207                         $('#example_next').click();
208                 },
209                 function () { return document.getElementById('example_info').innerHTML == "Showing 51 to 57 of 57 entries"; }
210         );
211         
212         oTest.fnTest(
213                 "Information back on first page",
214                 function () {
215                         $('#example_previous').click();
216                         $('#example_previous').click();
217                         $('#example_previous').click();
218                         $('#example_previous').click();
219                         $('#example_previous').click();
220                 },
221                 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
222         );
223         
224         oTest.fnTest(
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"; }
228         );
229         
230         oTest.fnTest(
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"; }
234         );
235         
236         oTest.fnTest(
237                 "Information with 100 records - first page",
238                 function () {
239                         $('#example_previous').click();
240                         $("select[name=example_length]").val('100').change();
241                 },
242                 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 57 of 57 entries"; }
243         );
244         
245         oTest.fnTest(
246                 "Information back to 10 records",
247                 function () {
248                         $('#example_previous').click();
249                         $("select[name=example_length]").val('10').change();
250                 },
251                 function () { return document.getElementById('example_info').innerHTML == "Showing 1 to 10 of 57 entries"; }
252         );
253         
254         oTest.fnTest(
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)"; }
259         );
260         
261         oTest.fnTest(
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)"; }
266         );
267         
268         oTest.fnTest(
269                 "Information with filter 'Win' last page",
270                 function () {
271                         $('#example_next').click();
272                         $('#example_next').click();
273                 },
274                 function () { return document.getElementById('example_info').innerHTML == 
275                         "Showing 31 to 31 of 31 entries (filtered from 57 total entries)"; }
276         );
277         
278         oTest.fnTest(
279                 "Information with filter 'Win' back to first page",
280                 function () {
281                         $('#example_previous').click();
282                         $('#example_previous').click();
283                         $('#example_previous').click();
284                 },
285                 function () { return document.getElementById('example_info').innerHTML == 
286                         "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
287         );
288         
289         oTest.fnTest(
290                 "Information with filter 'Win' second page - second time",
291                 function () {
292                         $('#example_next').click();
293                 },
294                 function () { return document.getElementById('example_info').innerHTML == 
295                         "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
296         );
297         
298         oTest.fnTest(
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)"; }
303         );
304         
305         oTest.fnTest(
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)"; }
310         );
311         
312         oTest.fnTest(
313                 "Information with filter 'Win' second page - third time",
314                 function () {
315                         $('#example_next').click();
316                 },
317                 function () { return document.getElementById('example_info').innerHTML == 
318                         "Showing 11 to 20 of 31 entries (filtered from 57 total entries)"; }
319         );
320         
321         oTest.fnTest(
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"; }
326         );
327         
328         
329         /*
330          * Filtering
331          */
332         oTest.fnWaitTest(
333                 "Filter 'W' - rows",
334                 function () { 
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"; }
340         );
341         
342         oTest.fnTest(
343                 "Filter 'W' - info",
344                 null,
345                 function () { return document.getElementById('example_info').innerHTML == 
346                         "Showing 1 to 10 of 42 entries (filtered from 57 total entries)"; }
347         );
348         
349         oTest.fnTest(
350                 "Filter 'Wi'",
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)"; }
354         );
355         
356         oTest.fnTest(
357                 "Filter 'Win'",
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)"; }
361         );
362         
363         oTest.fnTest(
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)"; }
367         );
368         
369         oTest.fnTest(
370                 "Filter 'Win' - sorting column 1 info",
371                 null,
372                 function () { return document.getElementById('example_info').innerHTML == 
373                         "Showing 1 to 10 of 31 entries (filtered from 57 total entries)"; }
374         );
375         
376         oTest.fnTest(
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"; }
380         );
381         
382         oTest.fnTest(
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"; }
386         );
387         
388         oTest.fnTest(
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"; }
392         );
393         
394         oTest.fnTest(
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"; }
398         );
399         
400         oTest.fnTest(
401                 "Filter 'Win' - sorting col 3 - reversed info",
402                 null,
403                 function () { return document.getElementById('example_info').innerHTML == 
404                         "Showing 1 to 6 of 6 entries (filtered from 57 total entries)"; }
405         );
406         
407         oTest.fnTest(
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"; }
412         );
413         
414         oTest.fnTest(
415                 "Filter 'nothinghere' - info",
416                 null,
417                 function () { return document.getElementById('example_info').innerHTML == 
418                         "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
419         );
420         
421         oTest.fnTest(
422                 "Filter back to blank and 1st column sorting",
423                 function () {
424                         $('#example_filter input').val("").keyup();
425                         $('#example thead th:eq(0)').click();
426                 },
427                 function () { return document.getElementById('example_info').innerHTML == 
428                         "Showing 1 to 10 of 57 entries"; }
429         );
430         
431         oTest.fnTest(
432                 "Prefixing a filter entry",
433                 function () {
434                         $('#example_filter input').val("Win").keyup();
435                         $('#example_filter input').val("GeckoWin").keyup();
436                 },
437                 function () { return document.getElementById('example_info').innerHTML == 
438                         "Showing 0 to 0 of 0 entries (filtered from 57 total entries)"; }
439         );
440         
441         oTest.fnTest(
442                 "Prefixing a filter entry with space",
443                 function () {
444                         $('#example_filter input').val("Gecko Win").keyup();
445                 },
446                 function () { return document.getElementById('example_info').innerHTML == 
447                         "Showing 1 to 10 of 17 entries (filtered from 57 total entries)"; }
448         );
449         
450         
451         
452         
453         
454         
455         
456         
457         oTest.fnComplete();
458 } );