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
|
describe('core - $()', function() {
dt.libs({
js: ['jquery', 'datatables'],
css: ['datatables']
});
var table;
describe('Check the defaults', function() {
dt.html('basic');
it('Exists and is a function', function() {
table = $('#example').DataTable();
expect(typeof table.$).toBe('function');
});
it('Returns a jQuery instance', function() {
expect(table.$('tr') instanceof $).toBe(true);
});
});
describe('Functional tests', function() {
dt.html('basic');
it('Selector - node', function() {
table = $('#example').DataTable();
expect(table.$(table.cell(2, 0).node()).text()).toBe('Ashton Cox');
});
it('Selector - jQuery', function() {
expect(table.$($('tbody tr:eq(2) td:eq(0)')).text()).toBe('Ashton Cox');
});
it('Selector - string', function() {
expect(table.$('td:contains("Cox")').text()).toBe('Ashton Cox');
});
it('Modifer - none', function() {
expect(table.$('tr').length).toBe(57);
});
it('Modifer - page', function() {
expect(table.$('tr', { page: 'current' }).length).toBe(10);
});
it('Modifer - order - original', function() {
expect(
table
.$('tr:eq(0)', { order: 'original' })
.text()
.trim()
.split(' ')[0]
).toBe('Tiger');
});
it('Modifer - order - current', function() {
expect(
table
.$('tr:eq(0)', { order: 'current' })
.text()
.trim()
.split(' ')[0]
).toBe('Airi');
});
});
});
|