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
|
describe( "order", function() {
dt.libs( {
js: [ 'jquery', 'datatables' ],
css: [ 'datatables' ]
} );
describe("Check defaults", function () {
dt.html( 'basic' );
it("Check disabled by default", function () {
$('#example').dataTable();
expect($('#example').DataTable().settings()[0].oFeatures.aaSorting).toBe(undefined);
});
it("First column should be sorted- asc by default", function () {
expect($('#example tbody tr:eq(0) td:eq(0)').html() == "Airi Satou").toBe(true);
});
});
describe("Check can be enabled", function () {
dt.html( 'basic' );
it("Single Column Sort -Asc", function () {
$('#example').dataTable( {
"order": [1, 'asc']
});
expect($('#example tbody tr:eq(0) td:eq(1)').html() == "Accountant").toBe(true);
});
it("Single column sort- Desc", function () {
$('#example').dataTable( {
"order": [1, 'desc'],
"destroy": true
});
expect($('#example tbody tr:eq(0) td:eq(1)').html() == "Technical Author").toBe(true);
});
it("Two Column Sort- Both Asc", function () {
$('#example').dataTable( {
"order": [[ 0, 'asc' ], [ 1, 'asc' ]],
"destroy": true
});
expect($('#example tbody tr:eq(0) td:eq(1)').html() == "Accountant").toBe(true);
expect($('#example tbody tr:eq(0) td:eq(0)').html() == "Airi Satou").toBe(true);
});
it("Two Column Sort- Both Desc", function () {
$('#example').dataTable( {
"order": [[ 0, 'desc' ], [ 1, 'desc' ]],
"destroy": true
});
expect($('#example tbody tr:eq(0) td:eq(1)').html() == "Software Engineer").toBe(true);
expect($('#example tbody tr:eq(0) td:eq(0)').html() == "Zorita Serrano").toBe(true);
});
it("Two Column Sort- One Desc, One Asc", function () {
$('#example').dataTable( {
"order": [[ 2, 'asc' ], [ 1, 'desc' ]],
"destroy": true
});
expect($('#example tbody tr:eq(0) td:eq(1)').html() == "System Architect").toBe(true);
expect($('#example tbody tr:eq(0) td:eq(2)').html() == "Edinburgh").toBe(true);
});
});
});
|