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
|
describe('rows - row().id()', function() {
dt.libs({
js: ['jquery', 'datatables'],
css: ['datatables']
});
let table;
describe('Check the defaults', function() {
dt.html('basic');
it('Exists and is a function', function() {
table = $('#example').DataTable();
expect(typeof table.row().id).toBe('function');
});
it('Returns string', function() {
expect(typeof table.row().id()).toBe('string');
});
});
describe('Functional tests', function() {
dt.html('basic');
it('No ID set and no param', function() {
table = $('#example').DataTable();
expect(table.row(0).id()).toBe('undefined');
});
it('No ID set and true param', function() {
expect(table.row(0).id(true)).toBe('#undefined');
});
it('No ID set and false param', function() {
expect(table.row(0).id(false)).toBe('undefined');
});
dt.html('empty');
it('ID set and no param', function(done) {
table = $('#example').DataTable({
ajax: '/base/test/data/data.txt',
columns: [
{ data: 'name' },
{ data: 'position' },
{ data: 'office' },
{ data: 'age' },
{ data: 'start_date' },
{ data: 'salary' }
],
rowId: 'name',
initComplete: function(settings, json) {
expect(table.row(0).id()).toBe('Tiger Nixon');
done();
}
});
});
it('ID set and true param', function() {
expect(table.row(0).id(true)).toBe('#Tiger Nixon');
});
it('ID set and false param', function() {
expect(table.row(0).id(false)).toBe('Tiger Nixon');
});
});
});
|