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
|
describe('columns - column().index()', 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().index).toBe('function');
});
it('Returns an integer', function() {
var table = $('#example').DataTable();
expect(Number.isInteger(table.column().index())).toBe(true);
});
});
describe('Check behaviour', function() {
dt.html('basic');
it('Returns column index (no hidden columns)', function() {
var table = $('#example').DataTable();
expect(table.column(1).index()).toBe(1);
expect(table.column(1).index('data')).toBe(1);
expect(table.column(1).index('visible')).toBe(1);
});
dt.html('basic');
it('Correct column index before hidden columns', function() {
var table = $('#example').DataTable();
table.column(2).visible(false);
expect(table.column(1).index()).toBe(1);
expect(table.column(1).index('data')).toBe(1);
expect(table.column(1).index('visible')).toBe(1);
});
dt.html('basic');
it('Correct column index on hidden columns', function() {
var table = $('#example').DataTable();
table.column(1).visible(false);
expect(table.column(1).index()).toBe(1);
expect(table.column(1).index('data')).toBe(1);
expect(table.column(1).index('visible')).toBe(null);
});
dt.html('basic');
it('Correct column index after hidden columns', function() {
var table = $('#example').DataTable();
table.column(1).visible(false);
expect(table.column(2).index()).toBe(2);
expect(table.column(2).index('data')).toBe(2);
expect(table.column(2).index('visible')).toBe(1);
});
});
});
|