|
1 | 1 | ; (function ($) { |
2 | 2 | var debug = true, |
| 3 | + getRowCount$Select = function () { |
| 4 | + return $("select[name='table-id_length']"); |
| 5 | + }, |
3 | 6 | queryStringToObject = function (queryString) { |
4 | 7 | var vars = queryString.split('&'), |
5 | 8 | returnVar = {}; |
|
170 | 173 | var $testTbl = $($.fn.dataTable.fnTables()[0]), |
171 | 174 | $dtHead = $testTbl.children('thead'); |
172 | 175 | //test datatable has been applied |
173 | | - expect(4); |
| 176 | + expect(5); |
174 | 177 | ok($testTbl.length && $testTbl[0].tagName.toLowerCase() == 'table', "an instantiated datatable is expected to be found before window.onLoad"); |
175 | 178 | //test appropriate input elements are placed |
176 | 179 | equal($dtHead.find('input').filter(".hasDatepicker").length, 2, "2 datepicker elements are expected"); |
177 | 180 | equal($dtHead.find('select').length, 2, "2 select elements are expected"); |
178 | 181 | ok($dtHead.find('button').length, "a button element is expected"); |
| 182 | + ok(getRowCount$Select().length == 1, "select element found which denotes number of records to retrieve from server") |
179 | 183 | }); |
180 | 184 |
|
181 | 185 | asyncTest("data sent to and returned from server is OK", function (assert) { |
182 | | - expect(12); |
| 186 | + expect(13); |
183 | 187 | stop(); |
184 | 188 | dTAjaxController.add({ |
185 | 189 | runSendIfNoEcho: true, |
|
212 | 216 | }); |
213 | 217 | assert.isNumeric(tableIds, "first column of table contains only numeric text"); |
214 | 218 | deepEqual(tableIds, listIds, "JSON translated to table"); |
| 219 | + ok(getRowCount$Select().val() == tableIds.length, "number of rows returned corresponds to number of entries selected") |
215 | 220 | start(); |
216 | 221 | } |
217 | 222 | }); |
|
225 | 230 | triggerClick = function () { |
226 | 231 | $id.trigger("click"); |
227 | 232 | }, |
228 | | - ordered = $.map($(Array(10)), function (val, i) { return i+1+""; }), |
229 | | - reverseOrdered = $.map($(Array(10)), function (val, i) { return 100-i+""; }), |
| 233 | + records = parseInt(getRowCount$Select().val(),10), |
| 234 | + ordered = $.map($(new Array(records)), function (val, i) { |
| 235 | + return i + 1 + ""; |
| 236 | + }), |
| 237 | + reverseOrdered = $.map($(new Array(records)), function (val, i) { |
| 238 | + return 100 - i + ""; |
| 239 | + }), |
230 | 240 | secondClickExpect; |
231 | 241 | expect(2); |
232 | 242 | stop(); |
|
0 commit comments