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 / fnCookieCallback.js
1 // DATA_TEMPLATE: dom_data
2 oTest.fnStart( "Cookie callback" );
3
4
5 $(document).ready( function () {
6         var mPass;
7         /* Note that in order to be fully effective here for saving state, there would need to be a
8          * stringify function to serialise the data array
9          */
10         
11         oTest.fnTest( 
12                 "null by default",
13                 function () {
14                         $('#example').dataTable();
15                 },
16                 function () { return $('#example').dataTable().fnSettings().fnCookieCallback == null; }
17         );
18         
19         oTest.fnTest( 
20                 "Number of arguments",
21                 function () {
22                         $('#example').dataTable( {
23                                 "bDestroy": true,
24                                 "bStateSave": true,
25                                 "fnCookieCallback": function (sName, oData, sExpires, sPath) {
26                                         mPass = arguments.length;
27                                         return sName + "=; expires=" + sExpires +"; path=" + sPath;
28                                 }
29                         } );
30                 },
31                 function () { return mPass == 4; }
32         );
33         
34         oTest.fnTest( 
35                 "Name",
36                 function () {
37                         $('#example').dataTable( {
38                                 "bDestroy": true,
39                                 "bStateSave": true,
40                                 "fnCookieCallback": function (sName, oData, sExpires, sPath) {
41                                         mPass = sName=="SpryMedia_DataTables_example_dom_data.php";
42                                         return sName + "=; expires=" + sExpires +"; path=" + sPath;
43                                 }
44                         } );
45                 },
46                 function () { return mPass; }
47         );
48         
49         oTest.fnTest( 
50                 "Data",
51                 function () {
52                         $('#example').dataTable( {
53                                 "bDestroy": true,
54                                 "bStateSave": true,
55                                 "fnCookieCallback": function (sName, oData, sExpires, sPath) {
56                                         mPass = typeof oData.iStart != 'undefined';
57                                         return sName + "=; expires=" + sExpires +"; path=" + sPath;
58                                 }
59                         } );
60                 },
61                 function () { return mPass; }
62         );
63         
64         oTest.fnTest( 
65                 "Expires",
66                 function () {
67                         $('#example').dataTable( {
68                                 "bDestroy": true,
69                                 "bStateSave": true,
70                                 "fnCookieCallback": function (sName, oData, sExpires, sPath) {
71                                         mPass = typeof sExpires == 'string';
72                                         return sName + "=; expires=" + sExpires +"; path=" + sPath;
73                                 }
74                         } );
75                 },
76                 function () { return mPass; }
77         );
78         
79         oTest.fnTest( 
80                 "Path",
81                 function () {
82                         $('#example').dataTable( {
83                                 "bDestroy": true,
84                                 "bStateSave": true,
85                                 "fnCookieCallback": function (sName, oData, sExpires, sPath) {
86                                         mPass = sPath.match(/media\/unit_testing\/templates/);
87                                         return sName + "=; expires=" + sExpires +"; path=" + sPath;
88                                 }
89                         } );
90                 },
91                 function () { return mPass; }
92         );
93         
94         
95         oTest.fnCookieDestroy( $('#example').dataTable() );
96         oTest.fnComplete();
97 } );