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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
|
// todo tests
// - Confirm it exists and is a function
// - Confirm it returns a node
// - One row in footer:
// - Select the first column and get its footer cell
// - Select the last column and get its footer cell
// - Two rows in footer:
// - Select the first column and get its footer cell - only first cell for that column is returned
// - Select the last column and get its footer cell - only first cell for that column is returned
// - Test with no footer, make sure null is returned for all columns
// - Test with a scrolling table that has a footer
// - Hide a column - ensure that its footer node can still be accessed with this method
describe( "columns- column().footer()", 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.column().footer).toBe('function');
});
dt.html( 'basic' );
it("Returns an API instance", function () {
var table = $('#example').DataTable();
expect(table.column().footer() instanceof Node).toBe(true);
});
dt.html( 'basic' );
it("One row in footer: Select first column return footer cell", function () {
var table = $('#example').DataTable();
var returnData = table.column(0).footer();
expect(returnData.nodeName == "TH" && returnData.textContent == "Name").toBe(true);
});
dt.html( 'basic' );
it("One row in footer: Select last column return footer cell", function () {
var table = $('#example').DataTable();
var returnData = table.column(-1).footer();
expect(returnData.nodeName == "TH" && returnData.textContent == "Salary").toBe(true);
});
dt.html( 'two_footers' );
it("Two rows in footer: Select last column return footer cell", function () {
var table = $('#example').DataTable();
var returnData = table.column(0).footer();
expect(returnData.nodeName == "TH" && returnData.textContent == "Name").toBe(true);
});
dt.html( 'two_footers' );
it("One row in footer: Select last column return footer cell", function () {
var table = $('#example').DataTable();
var returnData = table.column(-1).footer();
expect(returnData.nodeName == "TH" && returnData.textContent == "Salary").toBe(true);
});
dt.html( 'no_footer' );
it("One row in footer: Select last column return footer cell", function () {
var table = $('#example').DataTable();
var returnData = table.column(0).footer();
expect(returnData).toBe(null);
});
dt.html('basic');
it("Scrolling table with footer", function () {
var table = $('#example').DataTable({
"scrollY": "200px",
"scrollCollapse": true,
"paging": false
});
var returnData = table.column(0).footer();
expect(returnData.nodeName == "TH" && returnData.textContent == "Name").toBe(true);
});
dt.html( 'basic' );
it("Hidden column", function () {
var table = $('#example').DataTable({
"columnDefs": [
{
"targets": [ 0 ],
"visible": false,
"searchable": false
}
]
});
var returnData = table.column(0).footer();
expect(returnData.nodeName == "TH" && returnData.textContent == "Name").toBe(true);
});
});
});
|