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 / fnRowCallback.js
1 // DATA_TEMPLATE: dom_data
2 oTest.fnStart( "fnRowCallback" );
3
4 /* Note - fnRowCallback MUST return the first arguments (modified or not) */
5
6 $(document).ready( function () {
7         /* Check the default */
8         var oTable = $('#example').dataTable();
9         var oSettings = oTable.fnSettings();
10         var mPass;
11         
12         oTest.fnTest( 
13                 "Default should be null",
14                 null,
15                 function () { return oSettings.fnRowCallback == null; }
16         );
17         
18         
19         oTest.fnTest( 
20                 "Four arguments passed",
21                 function () {
22                         oSession.fnRestore();
23                         
24                         mPass = -1;
25                         $('#example').dataTable( {
26                                 "fnRowCallback": function ( nTr ) {
27                                         mPass = arguments.length;
28                                         return nTr;
29                                 }
30                         } );
31                 },
32                 function () { return mPass == 4; }
33         );
34         
35         
36         oTest.fnTest( 
37                 "fnRowCallback called once for each drawn row",
38                 function () {
39                         oSession.fnRestore();
40                         
41                         mPass = 0;
42                         $('#example').dataTable( {
43                                 "fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) {
44                                         mPass++;
45                                         return nTr;
46                                 }
47                         } );
48                 },
49                 function () { return mPass == 10; }
50         );
51         
52         oTest.fnTest( 
53                 "fnRowCallback allows us to alter row information",
54                 function () {
55                         oSession.fnRestore();
56                         $('#example').dataTable( {
57                                 "fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) {
58                                         $(nTr).addClass('unit_test');
59                                         return nTr;
60                                 }
61                         } );
62                 },
63                 function () { return $('#example tbody tr:eq(1)').hasClass('unit_test'); }
64         );
65         
66         oTest.fnTest( 
67                 "Data array has length matching columns",
68                 function () {
69                         oSession.fnRestore();
70                         
71                         mPass = true;
72                         $('#example').dataTable( {
73                                 "fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) {
74                                         if ( asData.length != 5 )
75                                                 mPass = false;
76                                         return nTr;
77                                 }
78                         } );
79                 },
80                 function () { return mPass; }
81         );
82         
83         oTest.fnTest( 
84                 "Data array has length matching columns",
85                 function () {
86                         oSession.fnRestore();
87                         
88                         mPass = true;
89                         var iCount = 0;
90                         $('#example').dataTable( {
91                                 "fnRowCallback": function ( nTr, asData, iDrawIndex, iDataIndex ) {
92                                         if ( iCount != iDrawIndex )
93                                                 mPass = false;
94                                         iCount++;
95                                         return nTr;
96                                 }
97                         } );
98                 },
99                 function () { return mPass; }
100         );
101         
102         
103         
104         oTest.fnComplete();
105 } );