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

Contents of /misc/horsensspejder-web/jquery/DataTables-1.9.4/media/unit_testing/tests_onhold/1_dom/_setDataFunctions.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: 3737 byte(s)
initial import
1 // DATA_TEMPLATE: dom_data
2 oTest.fnStart( "Check behaviour of the data set functions that DataTables uses" );
3
4 $(document).ready( function () {
5 // Slightly unusual test set this one, in that we don't really care about the DOM
6 // but want to test the internal data handling functions but we do need a table to
7 // get at the functions!
8 var table = $('#example').dataTable();
9 var fn, test, o;
10
11 // Object property access
12 oTest.fnTest(
13 "Create property",
14 function () {
15 fn = table.oApi._fnSetObjectDataFn('test');
16
17 o = {};
18 fn( o, true );
19 },
20 function () { return o.test }
21 );
22
23 oTest.fnTest(
24 "Single property doesn't kill other properties",
25 function () {
26 fn = table.oApi._fnSetObjectDataFn('test');
27
28 o = {
29 "test2": false
30 };
31 fn( o, true );
32 },
33 function () { return o.test && o.test2===false; }
34 );
35
36 oTest.fnTest(
37 "Single property overwrite old property",
38 function () {
39 fn = table.oApi._fnSetObjectDataFn('test');
40
41 o = {
42 "test": false,
43 "test2": false
44 };
45 fn( o, true );
46 },
47 function () { return o.test && o.test2===false; }
48 );
49
50
51 // Nested
52 oTest.fnTest(
53 "Create nested property",
54 function () {
55 fn = table.oApi._fnSetObjectDataFn('test.inner');
56
57 o = {
58 "test": {}
59 };
60 fn( o, true );
61 },
62 function () { return o.test.inner }
63 );
64
65 oTest.fnTest(
66 "Deep create nested property",
67 function () {
68 fn = table.oApi._fnSetObjectDataFn('test.inner');
69
70 o = {};
71 fn( o, true );
72 },
73 function () { return o.test.inner }
74 );
75
76 oTest.fnTest(
77 "Nested property doesn't kill other properties",
78 function () {
79 fn = table.oApi._fnSetObjectDataFn('test.inner');
80
81 o = {
82 "test": {
83 "test2": false
84 }
85 };
86 fn( o, true );
87 },
88 function () { return o.test.inner && o.test.test2===false; }
89 );
90
91 oTest.fnTest(
92 "Single property overwrite old property",
93 function () {
94 fn = table.oApi._fnSetObjectDataFn('nested.test');
95
96 o = {
97 "nested": {
98 "test": false,
99 "test2": false
100 }
101 };
102 fn( o, true );
103 },
104 function () { return o.nested.test && o.nested.test2===false; }
105 );
106
107 // Set arrays / objects
108 oTest.fnTest(
109 "Create object",
110 function () {
111 fn = table.oApi._fnSetObjectDataFn('test');
112
113 o = {};
114 fn( o, {"a":true, "b":false} );
115 },
116 function () { return o.test.a && o.test.b===false }
117 );
118
119 oTest.fnTest(
120 "Create nested object",
121 function () {
122 fn = table.oApi._fnSetObjectDataFn('nested.test');
123
124 o = {};
125 fn( o, {"a":true, "b":false} );
126 },
127 function () { return o.nested.test.a && o.nested.test.b===false }
128 );
129
130 oTest.fnTest(
131 "Create array",
132 function () {
133 fn = table.oApi._fnSetObjectDataFn('test');
134
135 o = {};
136 fn( o, [1,2,3] );
137 },
138 function () { return o.test[0]===1 && o.test[2]===3 }
139 );
140
141 oTest.fnTest(
142 "Create nested array",
143 function () {
144 fn = table.oApi._fnSetObjectDataFn('nested.test');
145
146 o = {};
147 fn( o, [1,2,3] );
148 },
149 function () { return o.nested.test[0]===1 && o.nested.test[2]===3 }
150 );
151
152
153 // Array notation
154 oTest.fnTest(
155 "Create array of objects",
156 function () {
157 fn = table.oApi._fnSetObjectDataFn('test[].a');
158
159 o = {};
160 fn( o, [1,2,3] );
161 },
162 function () { return o.test.length===3 && o.test[0].a===1 && o.test[1].a===2; }
163 );
164
165 oTest.fnTest(
166 "Create array of nested objects",
167 function () {
168 fn = table.oApi._fnSetObjectDataFn('test[].a.b');
169
170 o = {};
171 fn( o, [1,2,3] );
172 },
173 function () { return o.test.length===3 && o.test[0].a.b===1 && o.test[1].a.b===2; }
174 );
175
176 oTest.fnTest(
177 "Create array",
178 function () {
179 fn = table.oApi._fnSetObjectDataFn('test[]');
180
181 o = {};
182 fn( o, [1,2,3] );
183 },
184 function () { return o.test.length===3 && o.test[0]===1 && o.test[1]===2; }
185 );
186
187
188
189 oTest.fnComplete();
190 } );

  ViewVC Help
Powered by ViewVC 1.1.20