1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
// todo tests
// 1- GET- return row ID, check it matches value set in rowId option
// 2- only one param and is type bool
// 3- Append a hash to row id then check we can select it using a selector.
describe( "rows- row().id()", function() {
dt.libs( {
js: [ 'jquery', 'datatables' ],
css: [ 'datatables' ]
} );
describe("Check the defaults", function () {
dt.html( 'basic' );
it("Exists and is a function", function () {
var table = $('#example').DataTable();
expect(typeof table.row().id).toBe('function');
});
dt.html( 'basic' );
it("Returns String or Undefined instance", function () {
var table = $('#example').DataTable();
expect(table.row(0).id()).toBe('undefined');
});
dt.html( 'empty' );
it("Return row id and matches rowId option", function (done) {
var table = $('#example').DataTable({
"ajax": '/base/test/data/data.txt',
columns: [
{ data: "name" },
{ data: "position" },
{ data: "office" },
{ data: "extn" },
{ data: "start_date" },
{ data: "salary" }
],
rowId: 'name',
initComplete: function ( settings, json ) {
var result = table.row(0).id();
expect(result === "Tiger Nixon").toBe(true);
done();
}
});
});
dt.html( 'empty' );
it("Append hash, select", function (done) {
var table = $('#example').DataTable({
"ajax": '/base/test/data/data.txt',
columns: [
{ data: "name" },
{ data: "position" },
{ data: "office" },
{ data: "extn" },
{ data: "start_date" },
{ data: "salary" }
],
rowId: 'name',
initComplete: function ( settings, json ) {
var result = table.row(0).id(true);
expect(result === "#Tiger Nixon").toBe(true);
done();
}
});
});
});
});
|