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

Contents of /misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/1_dom/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, 3 months ago) by torben
File MIME type: application/javascript
File size: 2103 byte(s)
initial import
1 // DATA_TEMPLATE: dom_data
2 oTest.fnStart( "fnCreatedRow tests" );
3
4 $(document).ready( function () {
5 var tmp = 0;
6
7 $('#example').dataTable( {
8 fnCreatedRow: function () {
9 tmp++;
10 }
11 } );
12
13 oTest.fnTest(
14 "Row created is called once for each row on init",
15 null,
16 function () { return tmp===57; }
17 );
18
19 oTest.fnTest(
20 "Created isn't called back on other draws",
21 function () { $('#example th:eq(1)').click(); },
22 function () { return tmp===57; }
23 );
24
25 oTest.fnTest(
26 "Three arguments for the function",
27 function () {
28 oSession.fnRestore();
29 tmp = true;
30
31 $('#example').dataTable( {
32 fnCreatedRow: function () {
33 if ( arguments.length !== 3 ) {
34 tmp = false;
35 }
36 }
37 } );
38 },
39 function () { return tmp; }
40 );
41
42 oTest.fnTest(
43 "First argument is a TR element",
44 function () {
45 oSession.fnRestore();
46 tmp = true;
47
48 $('#example').dataTable( {
49 fnCreatedRow: function () {
50 if ( arguments[0].nodeName !== "TR" ) {
51 tmp = false;
52 }
53 }
54 } );
55 },
56 function () { return tmp; }
57 );
58
59 oTest.fnTest(
60 "Second argument is an array with 5 elements",
61 function () {
62 oSession.fnRestore();
63 tmp = true;
64
65 $('#example').dataTable( {
66 fnCreatedRow: function () {
67 if ( arguments[1].length !== 5 ) {
68 tmp = false;
69 }
70 }
71 } );
72 },
73 function () { return tmp; }
74 );
75
76 oTest.fnTest(
77 "Third argument is the data source for the row",
78 function () {
79 oSession.fnRestore();
80 tmp = true;
81
82 $('#example').dataTable( {
83 fnCreatedRow: function () {
84 if ( arguments[1] !== this.fnSettings().aoData[ arguments[2] ]._aData ) {
85 tmp = false;
86 }
87 }
88 } );
89 },
90 function () { return tmp; }
91 );
92
93 oTest.fnTest(
94 "TR element is tied to the correct data",
95 function () {
96 oSession.fnRestore();
97 tmp = false;
98
99 $('#example').dataTable( {
100 fnCreatedRow: function (tr, data, index) {
101 if ( data[1] === "Firefox 1.0" ) {
102 if ( $('td:eq(3)', tr).html() == "1.7" ) {
103 tmp = true;
104 }
105 }
106 }
107 } );
108 },
109 function () { return tmp; }
110 );
111
112
113
114 oTest.fnComplete();
115 } );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.20