Add datatables-1.9.4 and jquery-1.10.2 libraries
[proteocache.git] / webapp / resources / datatables-1.9.4 / media / unit_testing / tests_onhold / 4_server-side / oSearch.js
1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "oSearch" );
3
4 /* Note with my server-side scripts the regex option has no effect - this just runs that down */
5
6 $(document).ready( function () {
7         /* Check the default */
8         var oTable = $('#example').dataTable( {
9                 "bServerSide": true,
10                 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php"
11         } );
12         var oSettings = oTable.fnSettings();
13         
14         oTest.fnWaitTest( 
15                 "Default values should be blank",
16                 null,
17                 function () {
18                         var bReturn = oSettings.oPreviousSearch.sSearch == "" && 
19                                       !oSettings.oPreviousSearch.bRegex;
20                         return bReturn;
21                 }
22         );
23         
24         /* This test might be considered iffy since the full object isn't given, but it's reasonable to
25          * expect DataTables to cope with this. It should just assumine regex false
26          */
27         oTest.fnWaitTest( 
28                 "Search term only in object",
29                 function () {
30                         oSession.fnRestore();
31                         oTable = $('#example').dataTable( {
32                                 "bServerSide": true,
33                 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
34                                 "oSearch": {
35                                         "sSearch": "Mozilla"
36                                 }
37                         } );
38                 },
39                 function () { return $('#example tbody tr:eq(0) td:eq(3)').html() == "1"; }
40         );
41         
42         oTest.fnWaitTest( 
43                 "New search will kill old one",
44                 function () {
45                         oTable.fnFilter("Opera");
46                 },
47                 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Opera 7.0"; }
48         );
49         
50         oTest.fnWaitTest( 
51                 "Search plain text term and escape regex true",
52                 function () {
53                         oSession.fnRestore();
54                         $('#example').dataTable( {
55                                 "bServerSide": true,
56                                 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
57                                 "oSearch": {
58                                         "sSearch": "DS",
59                                         "bRegex": false
60                                 }
61                         } );
62                 },
63                 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Nintendo DS browser"; }
64         );
65         
66         oTest.fnWaitTest( 
67                 "Search plain text term and escape regex false",
68                 function () {
69                         oSession.fnRestore();
70                         $('#example').dataTable( {
71                                 "bServerSide": true,
72                                 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
73                                 "oSearch": {
74                                         "sSearch": "Opera",
75                                         "bRegex": true
76                                 }
77                         } );
78                 },
79                 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Opera 7.0"; }
80         );
81         
82         oTest.fnWaitTest( 
83                 "Search regex text term and escape regex true",
84                 function () {
85                         oSession.fnRestore();
86                         $('#example').dataTable( {
87                                 "bServerSide": true,
88                                 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
89                                 "oSearch": {
90                                         "sSearch": "1.*",
91                                         "bRegex": false
92                                 }
93                         } );
94                 },
95                 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; }
96         );
97         
98         
99         oTest.fnComplete();
100 } );