/[projects]/misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/1_dom/aoColumns.fnRender.js
ViewVC logotype

Contents of /misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/1_dom/aoColumns.fnRender.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2125 - (show annotations) (download) (as text)
Wed Mar 12 19:30:05 2014 UTC (10 years, 3 months ago) by torben
File MIME type: application/javascript
File size: 3364 byte(s)
initial import
1 // DATA_TEMPLATE: dom_data
2 oTest.fnStart( "aoColumns.fnRender" );
3
4 $(document).ready( function () {
5 /* Check the default */
6 var mTmp = 0;
7 var oTable = $('#example').dataTable( {
8 "aoColumns": [
9 null,
10 { "fnRender": function (a) {
11 mTmp++;
12 return a.aData[a.iDataColumn];
13 } },
14 null,
15 null,
16 null
17 ]
18 } );
19 var oSettings = oTable.fnSettings();
20
21 oTest.fnTest(
22 "Single column - fnRender is called once for each row",
23 null,
24 function () { return mTmp == 57; }
25 );
26
27 oTest.fnTest(
28 "Confirm that fnRender passes two arguments with four parameters",
29 function () {
30 mTmp = true;
31 oSession.fnRestore();
32 oTable = $('#example').dataTable( {
33 "aoColumns": [
34 null,
35 { "fnRender": function (a, v) {
36 if ( arguments.length != 2 || typeof a.iDataRow=='undefined' ||
37 typeof a.iDataColumn=='undefined' || typeof a.aData=='undefined' ||
38 typeof a.mDataProp=='undefined' )
39 {
40 mTmp = false;
41 }
42 return a.aData[a.iDataColumn];
43 } },
44 null,
45 null,
46 null
47 ]
48 } );
49 },
50 function () { return mTmp; }
51 );
52
53 oTest.fnTest(
54 "fnRender iDataColumn is row number",
55 function () {
56 var iCount = 0;
57 mTmp = true;
58 oSession.fnRestore();
59 oTable = $('#example').dataTable( {
60 "aoColumns": [
61 null,
62 { "fnRender": function (a) {
63 if ( iCount != a.iDataRow )
64 {
65 mTmp = false;
66 }
67 iCount++;
68 return a.aData[a.iDataColumn];
69 } },
70 null,
71 null,
72 null
73 ]
74 } );
75 },
76 function () { return mTmp; }
77 );
78
79 oTest.fnTest(
80 "fnRender iDataColumn is the column",
81 function () {
82 mTmp = true;
83 oSession.fnRestore();
84 oTable = $('#example').dataTable( {
85 "aoColumns": [
86 null,
87 { "fnRender": function (a) {
88 if ( a.iDataColumn != 1 )
89 {
90 mTmp = false;
91 }
92 return a.aData[a.iDataColumn];
93 } },
94 null,
95 null,
96 null
97 ]
98 } );
99 },
100 function () { return mTmp; }
101 );
102
103 oTest.fnTest(
104 "fnRender aData is data array of correct size",
105 function () {
106 mTmp = true;
107 oSession.fnRestore();
108 oTable = $('#example').dataTable( {
109 "aoColumns": [
110 null,
111 { "fnRender": function (a) {
112 if ( a.aData.length != 5 )
113 {
114 mTmp = false;
115 }
116 return a.aData[a.iDataColumn];
117 } },
118 null,
119 null,
120 null
121 ]
122 } );
123 },
124 function () { return mTmp; }
125 );
126
127 oTest.fnTest(
128 "Passed back data is put into the DOM",
129 function () {
130 oSession.fnRestore();
131 oTable = $('#example').dataTable( {
132 "aoColumns": [
133 null,
134 { "fnRender": function (a) {
135 return 'unittest';
136 } },
137 null,
138 null,
139 null
140 ]
141 } );
142 },
143 function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'unittest'; }
144 );
145
146 oTest.fnTest(
147 "Passed back data is put into the DOM",
148 function () {
149 oSession.fnRestore();
150 oTable = $('#example').dataTable( {
151 "aoColumns": [
152 null,
153 null,
154 { "fnRender": function (a) {
155 return 'unittest1';
156 } },
157 { "fnRender": function (a) {
158 return 'unittest2';
159 } },
160 null
161 ]
162 } );
163 },
164 function () {
165 var bReturn =
166 $('#example tbody tr:eq(0) td:eq(2)').html() == 'unittest1' &&
167 $('#example tbody tr:eq(0) td:eq(3)').html() == 'unittest2';
168 return bReturn; }
169 );
170
171
172
173
174
175 oTest.fnComplete();
176 } );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20