Add datatables-1.9.4 and jquery-1.10.2 libraries
[proteocache.git] / webapp / resources / datatables-1.9.4 / media / unit_testing / tests_onhold / 2_js / aoSearchCols.js
1 // DATA_TEMPLATE: js_data
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                 "aaData": gaaData
10         } );
11         var oSettings = oTable.fnSettings();
12         
13         oTest.fnTest( 
14                 "Default should be to have a empty colums array",
15                 null,
16                 function () {
17                         var bReturn = 
18                                 oSettings.aoPreSearchCols[0].sSearch == 0 && !oSettings.aoPreSearchCols[0].bRegex &&
19                                 oSettings.aoPreSearchCols[1].sSearch == 0 && !oSettings.aoPreSearchCols[1].bRegex &&
20                                 oSettings.aoPreSearchCols[2].sSearch == 0 && !oSettings.aoPreSearchCols[2].bRegex &&
21                                 oSettings.aoPreSearchCols[3].sSearch == 0 && !oSettings.aoPreSearchCols[3].bRegex &&
22                                 oSettings.aoPreSearchCols[4].sSearch == 0 && !oSettings.aoPreSearchCols[4].bRegex;
23                         return bReturn;
24                 }
25         );
26         
27         
28         oTest.fnTest( 
29                 "Search on a single column - no regex statement given",
30                 function () {
31                         oSession.fnRestore();
32                         oTable = $('#example').dataTable( {
33                                 "aaData": gaaData,
34                                 "aoSearchCols": [
35                                         null,
36                                         { "sSearch": "Mozilla" },
37                                         null,
38                                         { "sSearch": "1" },
39                                         null
40                                 ]
41                         } );
42                 },
43                 function () { return $('#example_info').html() == "Showing 1 to 9 of 9 entries (filtered from 57 total entries)"; }
44         );
45         
46         oTest.fnTest( 
47                 "Search on two columns - no regex statement given",
48                 function () {
49                         oSession.fnRestore();
50                         oTable = $('#example').dataTable( {
51                                 "aaData": gaaData,
52                                 "aoSearchCols": [
53                                         null,
54                                         { "sSearch": "Mozilla" },
55                                         null,
56                                         { "sSearch": "1.5" },
57                                         null
58                                 ]
59                         } );
60                 },
61                 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "1.5"; }
62         );
63         
64         oTest.fnTest( 
65                 "Search on single column - escape regex false",
66                 function () {
67                         oSession.fnRestore();
68                         oTable = $('#example').dataTable( {
69                                 "aaData": gaaData,
70                                 "aoSearchCols": [
71                                         { "sSearch": ".*ML", "bEscapeRegex": false },
72                                         null,
73                                         null,
74                                         null,
75                                         null
76                                 ]
77                         } );
78                 },
79                 function () { return $('#example_info').html() == "Showing 1 to 3 of 3 entries (filtered from 57 total entries)"; }
80         );
81         
82         oTest.fnTest( 
83                 "Search on two columns - escape regex false on first, true on second",
84                 function () {
85                         oSession.fnRestore();
86                         oTable = $('#example').dataTable( {
87                                 "aaData": gaaData,
88                                 "aoSearchCols": [
89                                         { "sSearch": ".*ML", "bEscapeRegex": false },
90                                         { "sSearch": "3.3", "bEscapeRegex": true },
91                                         null,
92                                         null,
93                                         null
94                                 ]
95                         } );
96                 },
97                 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Konqureror 3.3"; }
98         );
99         
100         oTest.fnTest( 
101                 "Search on two columns (no records) - escape regex false on first, true on second",
102                 function () {
103                         oSession.fnRestore();
104                         oTable = $('#example').dataTable( {
105                                 "aaData": gaaData,
106                                 "aoSearchCols": [
107                                         { "sSearch": ".*ML", "bEscapeRegex": false },
108                                         { "sSearch": "Allan", "bEscapeRegex": true },
109                                         null,
110                                         null,
111                                         null
112                                 ]
113                         } );
114                 },
115                 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; }
116         );
117         
118         oTest.fnComplete();
119 } );