/[projects]/misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/4_server-side/fnCreatedRow.js
ViewVC logotype

Contents of /misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/4_server-side/fnCreatedRow.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, 2 months ago) by torben
File MIME type: application/javascript
File size: 3282 byte(s)
initial import
1 // DATA_TEMPLATE: empty_table
2 oTest.fnStart( "fnCreatedRow 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 fnCreatedRow: function () {
12 tmp++;
13 }
14 } );
15
16 oTest.fnWaitTest(
17 "Row created is called once for each row on init",
18 null,
19 function () { return tmp===10; }
20 );
21
22 oTest.fnWaitTest(
23 "Created is called back on other draws",
24 function () { $('#example th:eq(1)').click(); },
25 function () { return tmp===20; }
26 );
27
28 oTest.fnWaitTest(
29 "Three arguments for the function",
30 function () {
31 oSession.fnRestore();
32 tmp = true;
33 complete = false;
34
35 $('#example').dataTable( {
36 "bServerSide": true,
37 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
38 fnCreatedRow: function () {
39 if ( arguments.length !== 3 ) {
40 tmp = false;
41 }
42 },
43 fnInitComplete: function () {
44 complete = true;
45 }
46 } );
47 },
48 function () { return (tmp && complete); }
49 );
50
51 oTest.fnWaitTest(
52 "First argument is a TR element",
53 function () {
54 oSession.fnRestore();
55 tmp = true;
56 complete = false;
57
58 $('#example').dataTable( {
59 "bServerSide": true,
60 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
61 fnCreatedRow: function () {
62 if ( arguments[0].nodeName !== "TR" ) {
63 tmp = false;
64 }
65 },
66 fnInitComplete: function () {
67 complete = true;
68 }
69 } );
70 },
71 function () { return (tmp && complete); }
72 );
73
74 oTest.fnWaitTest(
75 "Second argument is an array with 5 elements",
76 function () {
77 oSession.fnRestore();
78 tmp = true;
79 complete = false;
80
81 $('#example').dataTable( {
82 "bServerSide": true,
83 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
84 fnCreatedRow: function () {
85 if ( arguments[1].length !== 5 ) {
86 tmp = false;
87 }
88 },
89 fnInitComplete: function () {
90 complete = true;
91 }
92 } );
93 },
94 function () { return (tmp && complete); }
95 );
96
97 oTest.fnWaitTest(
98 "Third argument is the data source for the row",
99 function () {
100 oSession.fnRestore();
101 tmp = true;
102 complete = false;
103
104 $('#example').dataTable( {
105 "bServerSide": true,
106 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
107 fnCreatedRow: function () {
108 if ( arguments[1] !== this.fnSettings().aoData[ arguments[2] ]._aData ) {
109 tmp = false;
110 }
111 },
112 fnInitComplete: function () {
113 complete = true;
114 }
115 } );
116 },
117 function () { return (tmp && complete); }
118 );
119
120 oTest.fnWaitTest(
121 "TR element is tied to the correct data",
122 function () {
123 oSession.fnRestore();
124 tmp = false;
125 complete = false;
126
127 $('#example').dataTable( {
128 "bServerSide": true,
129 "sAjaxSource": "../../../examples/server_side/scripts/server_processing.php",
130 fnCreatedRow: function (tr, data, index) {
131 if ( data[1] === "Firefox 1.0" ) {
132 if ( $('td:eq(3)', tr).html() == "1.7" ) {
133 tmp = true;
134 }
135 }
136 },
137 fnInitComplete: function () {
138 complete = true;
139 }
140 } );
141 },
142 function () { return (tmp && complete); }
143 );
144
145
146
147 oTest.fnComplete();
148 } );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20