Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions Mvc.JQuery.Datatables.Example/Scripts/QUnitTests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
; (function ($) {
var debug = true,
getRowCount$Select = function () {
return $("select[name='table-id_length']");
},
queryStringToObject = function (queryString) {
var vars = queryString.split('&'),
returnVar = {};
Expand Down Expand Up @@ -170,16 +173,17 @@
var $testTbl = $($.fn.dataTable.fnTables()[0]),
$dtHead = $testTbl.children('thead');
//test datatable has been applied
expect(4);
expect(5);
ok($testTbl.length && $testTbl[0].tagName.toLowerCase() == 'table', "an instantiated datatable is expected to be found before window.onLoad");
//test appropriate input elements are placed
equal($dtHead.find('input').filter(".hasDatepicker").length, 2, "2 datepicker elements are expected");
equal($dtHead.find('select').length, 2, "2 select elements are expected");
ok($dtHead.find('button').length, "a button element is expected");
ok(getRowCount$Select().length == 1, "select element found which denotes number of records to retrieve from server")
});

asyncTest("data sent to and returned from server is OK", function (assert) {
expect(12);
expect(13);
stop();
dTAjaxController.add({
runSendIfNoEcho: true,
Expand Down Expand Up @@ -212,6 +216,7 @@
});
assert.isNumeric(tableIds, "first column of table contains only numeric text");
deepEqual(tableIds, listIds, "JSON translated to table");
ok(getRowCount$Select().val() == tableIds.length, "number of rows returned corresponds to number of entries selected")
start();
}
});
Expand All @@ -225,8 +230,13 @@
triggerClick = function () {
$id.trigger("click");
},
ordered = $.map($(Array(10)), function (val, i) { return i+1+""; }),
reverseOrdered = $.map($(Array(10)), function (val, i) { return 100-i+""; }),
records = parseInt(getRowCount$Select().val(),10),
ordered = $.map($(new Array(records)), function (val, i) {
return i + 1 + "";
}),
reverseOrdered = $.map($(new Array(records)), function (val, i) {
return 100 - i + "";
}),
secondClickExpect;
expect(2);
stop();
Expand Down