Skip to content

Commit 8e9324e

Browse files
committed
js test - vary number of records
1 parent cb0a2db commit 8e9324e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Mvc.JQuery.Datatables.Example/Scripts/QUnitTests.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
; (function ($) {
22
var debug = true,
3+
getRowCount$Select = function () {
4+
return $("select[name='table-id_length']");
5+
},
36
queryStringToObject = function (queryString) {
47
var vars = queryString.split('&'),
58
returnVar = {};
@@ -170,16 +173,17 @@
170173
var $testTbl = $($.fn.dataTable.fnTables()[0]),
171174
$dtHead = $testTbl.children('thead');
172175
//test datatable has been applied
173-
expect(4);
176+
expect(5);
174177
ok($testTbl.length && $testTbl[0].tagName.toLowerCase() == 'table', "an instantiated datatable is expected to be found before window.onLoad");
175178
//test appropriate input elements are placed
176179
equal($dtHead.find('input').filter(".hasDatepicker").length, 2, "2 datepicker elements are expected");
177180
equal($dtHead.find('select').length, 2, "2 select elements are expected");
178181
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")
179183
});
180184

181185
asyncTest("data sent to and returned from server is OK", function (assert) {
182-
expect(12);
186+
expect(13);
183187
stop();
184188
dTAjaxController.add({
185189
runSendIfNoEcho: true,
@@ -212,6 +216,7 @@
212216
});
213217
assert.isNumeric(tableIds, "first column of table contains only numeric text");
214218
deepEqual(tableIds, listIds, "JSON translated to table");
219+
ok(getRowCount$Select().val() == tableIds.length, "number of rows returned corresponds to number of entries selected")
215220
start();
216221
}
217222
});
@@ -225,8 +230,13 @@
225230
triggerClick = function () {
226231
$id.trigger("click");
227232
},
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+
}),
230240
secondClickExpect;
231241
expect(2);
232242
stop();

0 commit comments

Comments
 (0)