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 / aoSearchCols.js
1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "aoSearchCols" );
3
4 /* We could be here forever testing this one, so we test a limited subset on a couple of colums */
5
6 $(document).ready( function () {
7         /* Check the default */
8         var oTable = $('#example').dataTable( {
9                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
10                 "aoColumns": [
11                         { "mData": "engine" },
12                         { "mData": "browser" },
13                         { "mData": "platform" },
14                         { "mData": "version" },
15                         { "mData": "grade" }
16                 ]
17         } );
18         var oSettings = oTable.fnSettings();
19         
20         oTest.fnWaitTest( 
21                 "Default should be to have a empty colums array",
22                 null,
23                 function () {
24                         var bReturn = 
25                                 oSettings.aoPreSearchCols[0].sSearch == 0 && !oSettings.aoPreSearchCols[0].bRegex &&
26                                 oSettings.aoPreSearchCols[1].sSearch == 0 && !oSettings.aoPreSearchCols[1].bRegex &&
27                                 oSettings.aoPreSearchCols[2].sSearch == 0 && !oSettings.aoPreSearchCols[2].bRegex &&
28                                 oSettings.aoPreSearchCols[3].sSearch == 0 && !oSettings.aoPreSearchCols[3].bRegex &&
29                                 oSettings.aoPreSearchCols[4].sSearch == 0 && !oSettings.aoPreSearchCols[4].bRegex;
30                         return bReturn;
31                 }
32         );
33         
34         
35         oTest.fnWaitTest( 
36                 "Search on a single column - no regex statement given",
37                 function () {
38                         oSession.fnRestore();
39                         oTable = $('#example').dataTable( {
40                                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
41                                 "aoColumnDefs": [
42                                         { "mData": "engine", "aTargets": [0] },
43                                         { "mData": "browser", "aTargets": [1] },
44                                         { "mData": "platform", "aTargets": [2] },
45                                         { "mData": "version", "aTargets": [3] },
46                                         { "mData": "grade", "aTargets": [4] }
47                                 ],
48                                 "aoSearchCols": [
49                                         null,
50                                         { "sSearch": "Mozilla" },
51                                         null,
52                                         { "sSearch": "1" },
53                                         null
54                                 ]
55                         } );
56                 },
57                 function () { return $('#example_info').html() == "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; }
58         );
59         
60         oTest.fnWaitTest( 
61                 "Search on two columns - no regex statement given",
62                 function () {
63                         oSession.fnRestore();
64                         oTable = $('#example').dataTable( {
65                                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
66                                 "aoColumnDefs": [
67                                         { "mData": "engine", "aTargets": [0] },
68                                         { "mData": "browser", "aTargets": [1] },
69                                         { "mData": "platform", "aTargets": [2] },
70                                         { "mData": "version", "aTargets": [3] },
71                                         { "mData": "grade", "aTargets": [4] }
72                                 ],
73                                 "aoSearchCols": [
74                                         null,
75                                         { "sSearch": "Mozilla" },
76                                         null,
77                                         { "sSearch": "1.5" },
78                                         null
79                                 ]
80                         } );
81                 },
82                 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "1.5"; }
83         );
84         
85         oTest.fnWaitTest( 
86                 "Search on single column - escape regex false",
87                 function () {
88                         oSession.fnRestore();
89                         oTable = $('#example').dataTable( {
90                                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
91                                 "aoColumnDefs": [
92                                         { "mData": "engine", "aTargets": [0] },
93                                         { "mData": "browser", "aTargets": [1] },
94                                         { "mData": "platform", "aTargets": [2] },
95                                         { "mData": "version", "aTargets": [3] },
96                                         { "mData": "grade", "aTargets": [4] }
97                                 ],
98                                 "aoSearchCols": [
99                                         { "sSearch": ".*ML", "bEscapeRegex": false },
100                                         null,
101                                         null,
102                                         null,
103                                         null
104                                 ]
105                         } );
106                 },
107                 function () { return $('#example_info').html() == "Showing 1 to 3 of 3 entries (filtered from 57 total entries)"; }
108         );
109         
110         oTest.fnWaitTest( 
111                 "Search on two columns - escape regex false on first, true on second",
112                 function () {
113                         oSession.fnRestore();
114                         oTable = $('#example').dataTable( {
115                                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
116                                 "aoColumnDefs": [
117                                         { "mData": "engine", "aTargets": [0] },
118                                         { "mData": "browser", "aTargets": [1] },
119                                         { "mData": "platform", "aTargets": [2] },
120                                         { "mData": "version", "aTargets": [3] },
121                                         { "mData": "grade", "aTargets": [4] }
122                                 ],
123                                 "aoSearchCols": [
124                                         { "sSearch": ".*ML", "bEscapeRegex": false },
125                                         { "sSearch": "3.3", "bEscapeRegex": true },
126                                         null,
127                                         null,
128                                         null
129                                 ]
130                         } );
131                 },
132                 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Konqureror 3.3"; }
133         );
134         
135         oTest.fnWaitTest( 
136                 "Search on two columns (no records) - escape regex false on first, true on second",
137                 function () {
138                         oSession.fnRestore();
139                         oTable = $('#example').dataTable( {
140                                 "sAjaxSource": "../../../examples/ajax/sources/objects.txt",
141                                 "aoColumnDefs": [
142                                         { "mData": "engine", "aTargets": [0] },
143                                         { "mData": "browser", "aTargets": [1] },
144                                         { "mData": "platform", "aTargets": [2] },
145                                         { "mData": "version", "aTargets": [3] },
146                                         { "mData": "grade", "aTargets": [4] }
147                                 ],
148                                 "aoSearchCols": [
149                                         { "sSearch": ".*ML", "bEscapeRegex": false },
150                                         { "sSearch": "Allan", "bEscapeRegex": true },
151                                         null,
152                                         null,
153                                         null
154                                 ]
155                         } );
156                 },
157                 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; }
158         );
159         
160         oTest.fnComplete();
161 } );