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 / oSearch.js
1 // DATA_TEMPLATE: js_data
2 oTest.fnStart( "oSearch" );
3
4 $(document).ready( function () {
5         /* Check the default */
6         var oTable = $('#example').dataTable( {
7                 "aaData": gaaData
8         } );
9         var oSettings = oTable.fnSettings();
10         
11         oTest.fnTest( 
12                 "Default values should be blank",
13                 null,
14                 function () {
15                         var bReturn = oSettings.oPreviousSearch.sSearch == "" && 
16                                       !oSettings.oPreviousSearch.bRegex;
17                         return bReturn;
18                 }
19         );
20         
21         /* This test might be considered iffy since the full object isn't given, but it's reasonable to
22          * expect DataTables to cope with this. It should just assumine regex false
23          */
24         oTest.fnTest( 
25                 "Search term only in object",
26                 function () {
27                         oSession.fnRestore();
28                         oTable = $('#example').dataTable( {
29                                 "aaData": gaaData,
30                                 "oSearch": {
31                                         "sSearch": "Mozilla"
32                                 }
33                         } );
34                 },
35                 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; }
36         );
37         
38         oTest.fnTest( 
39                 "New search will kill old one",
40                 function () {
41                         oTable.fnFilter("Opera");
42                 },
43                 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Presto"; }
44         );
45         
46         oTest.fnTest( 
47                 "Search plain text term and escape regex true",
48                 function () {
49                         oSession.fnRestore();
50                         $('#example').dataTable( {
51                                 "aaData": gaaData,
52                                 "oSearch": {
53                                         "sSearch": "DS",
54                                         "bRegex": false
55                                 }
56                         } );
57                 },
58                 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == "Nintendo DS browser"; }
59         );
60         
61         oTest.fnTest( 
62                 "Search plain text term and escape regex false",
63                 function () {
64                         oSession.fnRestore();
65                         $('#example').dataTable( {
66                                 "aaData": gaaData,
67                                 "oSearch": {
68                                         "sSearch": "Opera",
69                                         "bRegex": true
70                                 }
71                         } );
72                 },
73                 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Presto"; }
74         );
75         
76         oTest.fnTest( 
77                 "Search regex text term and escape regex true",
78                 function () {
79                         oSession.fnRestore();
80                         $('#example').dataTable( {
81                                 "aaData": gaaData,
82                                 "oSearch": {
83                                         "sSearch": "1.*",
84                                         "bRegex": false
85                                 }
86                         } );
87                 },
88                 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "No matching records found"; }
89         );
90         
91         oTest.fnTest( 
92                 "Search regex text term and escape regex false",
93                 function () {
94                         oSession.fnRestore();
95                         $('#example').dataTable( {
96                                 "aaData": gaaData,
97                                 "oSearch": {
98                                         "sSearch": "1.*",
99                                         "bRegex": true
100                                 }
101                         } );
102                 },
103                 function () { return $('#example tbody tr:eq(0) td:eq(0)').html() == "Gecko"; }
104         );
105         
106         
107         oTest.fnComplete();
108 } );