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 / fnCreatedCell.js
1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "fnCreatedCell tests" );
3
4 $(document).ready( function () {
5         var tmp = 0;
6         var complete = false;
7
8         $('#example').dataTable( {
9                 "bServerSide": true,
10                 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
11                 "aoColumnDefs": [ {
12                         fnCreatedCell: function () {
13                                 tmp++;
14                         },
15                         "aTargets": ["_all"]
16                 } ]
17         } );
18         
19         oTest.fnWaitTest( 
20                 "Cell created is called once for each cell on init",
21                 null,
22                 function () { return tmp===50; }
23         );
24         
25         oTest.fnWaitTest( 
26                 "Created is called back on other draws",
27                 function () { $('#example th:eq(1)').click(); },
28                 function () { return tmp===100; }
29         );
30
31         oTest.fnWaitTest(
32                 "Four arguments for the function",
33                 function () { 
34                         oSession.fnRestore();
35                         tmp = true;
36                         complete = false;
37
38                         $('#example').dataTable( {
39                                 "bServerSide": true,
40                                 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
41                                 "aoColumnDefs": [ {
42                                         fnCreatedRow: function () {
43                                                 if ( arguments.length !== 4 ) {
44                                                         tmp = false;
45                                                 }
46                                         },
47                                         "aTargets": ["_all"]
48                                 } ],
49                                 fnInitComplete: function () {
50                                         complete = true;
51                                 }
52                         } );
53                 },
54                 function () { return (tmp && complete); }
55         );
56
57         oTest.fnWaitTest(
58                 "First argument is a TD element",
59                 function () { 
60                         oSession.fnRestore();
61                         tmp = true;
62                         complete = false;
63
64                         $('#example').dataTable( {
65                                 "bServerSide": true,
66                                 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
67                                 "aoColumnDefs": [ {
68                                         fnCreatedRow: function () {
69                                                 if ( arguments[0].nodeName !== "TD" ) {
70                                                         tmp = false;
71                                                 }
72                                         },
73                                         "aTargets": ["_all"]
74                                 } ],
75                                 fnInitComplete: function () {
76                                         complete = true;
77                                 }
78                         } );
79                 },
80                 function () { return (tmp && complete); }
81         );
82
83         oTest.fnWaitTest(
84                 "Second argument is the HTML value",
85                 function () { 
86                         oSession.fnRestore();
87                         tmp = true;
88                         complete = false;
89
90                         $('#example').dataTable( {
91                                 "bServerSide": true,
92                                 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
93                                 "aoColumnDefs": [ {
94                                         fnCreatedRow: function () {
95                                                 if ( arguments[1] != $('td').html() ) {
96                                                         tmp = false;
97                                                 }
98                                         },
99                                         "aTargets": ["_all"]
100                                 } ],
101                                 fnInitComplete: function () {
102                                         complete = true;
103                                 }
104                         } );
105                 },
106                 function () { return (tmp && complete); }
107         );
108
109         oTest.fnWaitTest(
110                 "Third argument is the data array",
111                 function () { 
112                         oSession.fnRestore();
113                         tmp = true;
114                         complete = false;
115
116                         $('#example').dataTable( {
117                                 "bServerSide": true,
118                                 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
119                                 "aoColumnDefs": [ {
120                                         fnCreatedRow: function () {
121                                                 if ( arguments[2].length !== 5 ) {
122                                                         tmp = false;
123                                                 }
124                                         },
125                                         "aTargets": ["_all"]
126                                 } ],
127                                 fnInitComplete: function () {
128                                         complete = true;
129                                 }
130                         } );
131                 },
132                 function () { return (tmp && complete); }
133         );
134
135         oTest.fnWaitTest(
136                 "Fourth argument is the data source for the row",
137                 function () { 
138                         oSession.fnRestore();
139                         tmp = true;
140                         complete = false;
141
142                         $('#example').dataTable( {
143                                 "bServerSide": true,
144                                 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
145                                 "aoColumnDefs": [ {
146                                         fnCreatedRow: function () {
147                                                 if ( arguments[2] !== this.fnSettings().aoData[ arguments[2] ]._aData ) {
148                                                         tmp = false;
149                                                 }
150                                         },
151                                         "aTargets": ["_all"]
152                                 } ],
153                                 fnInitComplete: function () {
154                                         complete = true;
155                                 }
156                         } );
157                 },
158                 function () { return (tmp && complete); }
159         );
160
161         oTest.fnWaitTest(
162                 "Fifth argument is the the col index",
163                 function () { 
164                         oSession.fnRestore();
165                         tmp = true;
166                         complete = false;
167
168                         $('#example').dataTable( {
169                                 "bServerSide": true,
170                                 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
171                                 "aoColumnDefs": [ {
172                                         fnCreatedRow: function () {
173                                                 if ( arguments[1] != $('td:eq('+arguments[4]+')', arguments[0].parentNode).html() ) {
174                                                         tmp = false;
175                                                 }
176                                         },
177                                         "aTargets": ["_all"]
178                                 } ],
179                                 fnInitComplete: function () {
180                                         complete = true;
181                                 }
182                         } );
183                 },
184                 function () { return (tmp && complete); }
185         );
186         
187         
188         
189         oTest.fnComplete();
190 } );