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