Add datatables-1.9.4 and jquery-1.10.2 libraries
[proteocache.git] / webapp / resources / datatables-1.9.4 / media / unit_testing / tests_onhold / 1_dom / aaSorting.js
1 // DATA_TEMPLATE: dom_data
2 oTest.fnStart( "aaSorting" );
3
4 $(document).ready( function () {
5         /* Check the default */
6         var oTable = $('#example').dataTable();
7         var oSettings = oTable.fnSettings();
8         
9         oTest.fnTest( 
10                 "Default sorting is single column",
11                 null,
12                 function () {
13                         return oSettings.aaSorting.length == 1 && typeof oSettings.aaSorting[0] == 'object';
14                 }
15         );
16         
17         oTest.fnTest( 
18                 "Default sorting is first column asc",
19                 null,
20                 function () {
21                         return oSettings.aaSorting[0].length == 3 && oSettings.aaSorting[0][0] == 0 &&
22                                 oSettings.aaSorting[0][1] == 'asc';
23                 }
24         );
25         
26         oTest.fnTest( 
27                 "Sorting is applied",
28                 null,
29                 function () { return $('#example tbody td:eq(0)').html() == "Gecko"; }
30         );
31         
32         
33         oTest.fnTest( 
34                 "Custom sorting on single string column asc",
35                 function () {
36                         oSession.fnRestore();
37                         $('#example').dataTable( {
38                                 "aaSorting": [['1','asc']]
39                         } );
40                 },
41                 function () { return $('#example tbody td:eq(1)').html() == "All others"; }
42         );
43         
44         
45         oTest.fnTest( 
46                 "Custom sorting on single string column desc",
47                 function () {
48                         oSession.fnRestore();
49                         $('#example').dataTable( {
50                                 "aaSorting": [['1','desc']]
51                         } );
52                 },
53                 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
54         );
55         
56         
57         oTest.fnTest( 
58                 "Custom sorting on single int column asc",
59                 function () {
60                         oSession.fnRestore();
61                         $('#example').dataTable( {
62                                 "aaSorting": [['1','asc']]
63                         } );
64                 },
65                 function () { return $('#example tbody td:eq(3)').html() == "-"; }
66         );
67         
68         
69         oTest.fnTest( 
70                 "Custom sorting on single int column desc",
71                 function () {
72                         oSession.fnRestore();
73                         $('#example').dataTable( {
74                                 "aaSorting": [['1','desc']]
75                         } );
76                 },
77                 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
78         );
79         
80         
81         oTest.fnTest( 
82                 "Multi-column sorting (2 column) - string asc / string asc",
83                 function () {
84                         oSession.fnRestore();
85                         $('#example').dataTable( {
86                                 "aaSorting": [['0','asc'], ['1','asc']]
87                         } );
88                 },
89                 function () { return $('#example tbody td:eq(1)').html() == "Camino 1.0"; }
90         );
91         
92         oTest.fnTest( 
93                 "Multi-column sorting (2 column) - string asc / string desc",
94                 function () {
95                         oSession.fnRestore();
96                         $('#example').dataTable( {
97                                 "aaSorting": [['0','asc'], ['1','desc']]
98                         } );
99                 },
100                 function () { return $('#example tbody td:eq(1)').html() == "Seamonkey 1.1"; }
101         );
102         
103         oTest.fnTest( 
104                 "Multi-column sorting (2 column) - string desc / string asc",
105                 function () {
106                         oSession.fnRestore();
107                         $('#example').dataTable( {
108                                 "aaSorting": [['0','desc'], ['1','asc']]
109                         } );
110                 },
111                 function () { return $('#example tbody td:eq(1)').html() == "iPod Touch / iPhone"; }
112         );
113         
114         oTest.fnTest( 
115                 "Multi-column sorting (2 column) - string desc / string desc",
116                 function () {
117                         oSession.fnRestore();
118                         $('#example').dataTable( {
119                                 "aaSorting": [['0','desc'], ['1','desc']]
120                         } );
121                 },
122                 function () { return $('#example tbody td:eq(1)').html() == "Safari 3.0"; }
123         );
124         
125         
126         oTest.fnTest( 
127                 "Multi-column sorting (2 column) - string asc / int asc",
128                 function () {
129                         oSession.fnRestore();
130                         $('#example').dataTable( {
131                                 "aaSorting": [['0','asc'], ['3','asc']]
132                         } );
133                 },
134                 function () { return $('#example tbody td:eq(3)').html() == "1"; }
135         );
136         
137         oTest.fnTest( 
138                 "Multi-column sorting (2 column) - string asc / int desc",
139                 function () {
140                         oSession.fnRestore();
141                         $('#example').dataTable( {
142                                 "aaSorting": [['0','asc'], ['3','desc']]
143                         } );
144                 },
145                 function () { return $('#example tbody td:eq(3)').html() == "1.9"; }
146         );
147         
148         oTest.fnTest( 
149                 "Multi-column sorting (2 column) - string desc / int asc",
150                 function () {
151                         oSession.fnRestore();
152                         $('#example').dataTable( {
153                                 "aaSorting": [['0','desc'], ['3','asc']]
154                         } );
155                 },
156                 function () { return $('#example tbody td:eq(3)').html() == "125.5"; }
157         );
158         
159         oTest.fnTest( 
160                 "Multi-column sorting (2 column) - string desc / int desc",
161                 function () {
162                         oSession.fnRestore();
163                         $('#example').dataTable( {
164                                 "aaSorting": [['0','desc'], ['3','desc']]
165                         } );
166                 },
167                 function () { return $('#example tbody td:eq(3)').html() == "522.1"; }
168         );
169         
170         oTest.fnTest( 
171                 "Multi-column sorting (3 column) - string asc / int asc / string asc",
172                 function () {
173                         oSession.fnRestore();
174                         $('#example').dataTable( {
175                                 "aaSorting": [['0','asc'], ['3','asc'], ['1','asc']]
176                         } );
177                 },
178                 function () { return $('#example tbody tr:eq(7) td:eq(1)').html() == "Firefox 1.0"; }
179         );
180         
181         
182         oTest.fnComplete();
183 } );