comparison DataTables-1.9.4/media/unit_testing/tests_onhold/6_delayed_rendering/aoColumns.fnRender.js @ 0:ac5f9272033b draft

first upload
author saskia-hiltemann
date Tue, 01 Jul 2014 11:42:23 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:ac5f9272033b
1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "aoColumns.fnRender" );
3
4 $(document).ready( function () {
5 /* Check the default */
6 var mTmp = 0;
7 var oTable = $('#example').dataTable( {
8 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
9 "bDeferRender": true,
10 "aoColumns": [
11 null,
12 { "fnRender": function (a) {
13 mTmp++;
14 return a.aData[a.iDataColumn];
15 } },
16 null,
17 null,
18 null
19 ]
20 } );
21 var oSettings = oTable.fnSettings();
22
23 oTest.fnWaitTest(
24 "Single column - fnRender is called once for each row",
25 null,
26 function () { return mTmp == 57; }
27 );
28
29 oTest.fnWaitTest(
30 "Confirm that fnRender passes two arguments with four parameters",
31 function () {
32 mTmp = true;
33 oSession.fnRestore();
34 oTable = $('#example').dataTable( {
35 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
36 "bDeferRender": true,
37 "aoColumns": [
38 null,
39 { "fnRender": function (a) {
40 if ( arguments.length != 2 || typeof a.iDataRow=='undefined' ||
41 typeof a.iDataColumn=='undefined' || typeof a.aData=='undefined' ||
42 typeof a.mDataProp=='undefined' )
43 {
44 mTmp = false;
45 }
46 return a.aData[a.iDataColumn];
47 } },
48 null,
49 null,
50 null
51 ]
52 } );
53 },
54 function () { return mTmp; }
55 );
56
57 oTest.fnWaitTest(
58 "fnRender iDataColumn is row number",
59 function () {
60 var iCount = 0;
61 mTmp = true;
62 oSession.fnRestore();
63 oTable = $('#example').dataTable( {
64 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
65 "bDeferRender": true,
66 "aoColumns": [
67 null,
68 { "fnRender": function (a) {
69 if ( iCount != a.iDataRow )
70 {
71 mTmp = false;
72 }
73 iCount++;
74 return a.aData[a.iDataColumn];
75 } },
76 null,
77 null,
78 null
79 ]
80 } );
81 },
82 function () { return mTmp; }
83 );
84
85 oTest.fnWaitTest(
86 "fnRender iDataColumn is the column",
87 function () {
88 mTmp = true;
89 oSession.fnRestore();
90 oTable = $('#example').dataTable( {
91 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
92 "bDeferRender": true,
93 "aoColumns": [
94 null,
95 { "fnRender": function (a) {
96 if ( a.iDataColumn != 1 )
97 {
98 mTmp = false;
99 }
100 return a.aData[a.iDataColumn];
101 } },
102 null,
103 null,
104 null
105 ]
106 } );
107 },
108 function () { return mTmp; }
109 );
110
111 oTest.fnWaitTest(
112 "fnRender aData is data array of correct size",
113 function () {
114 mTmp = true;
115 oSession.fnRestore();
116 oTable = $('#example').dataTable( {
117 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
118 "bDeferRender": true,
119 "aoColumns": [
120 null,
121 { "fnRender": function (a) {
122 if ( a.aData.length != 5 )
123 {
124 mTmp = false;
125 }
126 return a.aData[a.iDataColumn];
127 } },
128 null,
129 null,
130 null
131 ]
132 } );
133 },
134 function () { return mTmp; }
135 );
136
137 oTest.fnWaitTest(
138 "Passed back data is put into the DOM",
139 function () {
140 oSession.fnRestore();
141 oTable = $('#example').dataTable( {
142 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
143 "bDeferRender": true,
144 "aoColumns": [
145 null,
146 { "fnRender": function (a) {
147 return 'unittest';
148 } },
149 null,
150 null,
151 null
152 ]
153 } );
154 },
155 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'unittest'; }
156 );
157
158 oTest.fnWaitTest(
159 "Passed back data is put into the DOM",
160 function () {
161 oSession.fnRestore();
162 oTable = $('#example').dataTable( {
163 "sAjaxSource": "../../../examples/ajax/sources/arrays.txt",
164 "bDeferRender": true,
165 "aoColumns": [
166 null,
167 null,
168 { "fnRender": function (a) {
169 return 'unittest1';
170 } },
171 { "fnRender": function (a) {
172 return 'unittest2';
173 } },
174 null
175 ]
176 } );
177 },
178 function () {
179 var bReturn =
180 $('#example tbody tr:eq(0) td:eq(2)').html() == 'unittest1' &&
181 $('#example tbody tr:eq(0) td:eq(3)').html() == 'unittest2';
182 return bReturn; }
183 );
184
185
186
187
188
189 oTest.fnComplete();
190 } );