Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebApplication/MVC2/HeuristicLabWeb.PluginHost/HLWebPluginHost/Content/jQuery/jQueryPlugins/DataTables-1.7.6/media/unit_testing/tests_onhold/1_dom/aoColumns.fnRender.js @ 6286

Last change on this file since 6286 was 6286, checked in by dkahn, 13 years ago

#1198 Added jQuery plus plugins

File size: 3.3 KB
Line 
1// DATA_TEMPLATE: dom_data
2oTest.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 one argument (an object) with three parameters",
29    function () {
30      mTmp = true;
31      oSession.fnRestore();
32      oTable = $('#example').dataTable( {
33        "aoColumns": [
34          null,
35          { "fnRender": function (a) {
36            if ( arguments.length != 1 || typeof a.iDataRow=='undefined' ||
37              typeof a.iDataColumn=='undefined' || typeof a.aData=='undefined' )
38            {
39              mTmp = false;
40            }
41            return a.aData[a.iDataColumn];
42          } },
43          null,
44          null,
45          null
46        ]
47      } );
48    },
49    function () { return mTmp; }
50  );
51 
52  oTest.fnTest(
53    "fnRender iDataColumn is row number",
54    function () {
55      var iCount = 0;
56      mTmp = true;
57      oSession.fnRestore();
58      oTable = $('#example').dataTable( {
59        "aoColumns": [
60          null,
61          { "fnRender": function (a) {
62            if ( iCount != a.iDataRow )
63            {
64              mTmp = false;
65            }
66            iCount++;
67            return a.aData[a.iDataColumn];
68          } },
69          null,
70          null,
71          null
72        ]
73      } );
74    },
75    function () { return mTmp; }
76  );
77 
78  oTest.fnTest(
79    "fnRender iDataColumn is the column",
80    function () {
81      mTmp = true;
82      oSession.fnRestore();
83      oTable = $('#example').dataTable( {
84        "aoColumns": [
85          null,
86          { "fnRender": function (a) {
87            if ( a.iDataColumn != 1 )
88            {
89              mTmp = false;
90            }
91            return a.aData[a.iDataColumn];
92          } },
93          null,
94          null,
95          null
96        ]
97      } );
98    },
99    function () { return mTmp; }
100  );
101 
102  oTest.fnTest(
103    "fnRender aData is data array of correct size",
104    function () {
105      mTmp = true;
106      oSession.fnRestore();
107      oTable = $('#example').dataTable( {
108        "aoColumns": [
109          null,
110          { "fnRender": function (a) {
111            if ( a.aData.length != 5 )
112            {
113              mTmp = false;
114            }
115            return a.aData[a.iDataColumn];
116          } },
117          null,
118          null,
119          null
120        ]
121      } );
122    },
123    function () { return mTmp; }
124  );
125 
126  oTest.fnTest(
127    "Passed back data is put into the DOM",
128    function () {
129      oSession.fnRestore();
130      oTable = $('#example').dataTable( {
131        "aoColumns": [
132          null,
133          { "fnRender": function (a) {
134            return 'unittest';
135          } },
136          null,
137          null,
138          null
139        ]
140      } );
141    },
142    function () { return $('#example tbody tr:eq(0) td:eq(1)').html() == 'unittest'; }
143  );
144 
145  oTest.fnTest(
146    "Passed back data is put into the DOM",
147    function () {
148      oSession.fnRestore();
149      oTable = $('#example').dataTable( {
150        "aoColumns": [
151          null,
152          null,
153          { "fnRender": function (a) {
154            return 'unittest1';
155          } },
156          { "fnRender": function (a) {
157            return 'unittest2';
158          } },
159          null
160        ]
161      } );
162    },
163    function () {
164      var bReturn =
165        $('#example tbody tr:eq(0) td:eq(2)').html() == 'unittest1' &&
166        $('#example tbody tr:eq(0) td:eq(3)').html() == 'unittest2';
167      return bReturn; }
168  );
169 
170 
171 
172 
173 
174  oTest.fnComplete();
175} );
Note: See TracBrowser for help on using the repository browser.