Skip to content
This repository was archived by the owner on Jan 7, 2022. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions src/components/DataTableDirective.e2e.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,56 @@
describe('DataTable: Sorting Demo', function () {
describe('sorting', function () {
var colHeaderList,
colHeader1,
colHeader1Icon,
colHeader2,
colHeader2Icon,
row1Column1;

beforeEach(function () {
browser.get('http://localhost:9000/demos/sort.html');

colHeaderList = by.repeater('column in header.columns[\'center\'] track by column.$id');
colHeader1 = element(colHeaderList.row(0));
colHeader1Icon = colHeader1.element(by.css('.sort-btn'));
colHeader2 = element(colHeaderList.row(1));
colHeader2Icon = colHeader2.element(by.css('.sort-btn'));
row1Column1 = element.all(by.css('.dt-cell')).first();
});

describe('multi column', function () {
it('should be able to sort by multiple columns', function() {
colHeader1.click();

expect(hasClass(colHeader1Icon, 'icon-up')).toBe(true);
expect(hasClass(colHeader2Icon, 'icon-down')).toBe(true);
expect(row1Column1.getText()).toBe('Valarie Atkinson');
});
});

describe('single column', function () {
beforeEach(function () {
element(by.model('multiple')).click();
});

it('should only sort by one column at a time', function () {
colHeader2.click();

setTimeout(function () {
colHeader1.click();
}, 10);

setTimeout(function () {
expect(hasClass(colHeader1Icon, 'icon-up')).toBe(true);
expect(hasClass(colHeader2Icon, 'icon-down')).toBe(false);
expect(row1Column1.getText()).toBe('Wilder Gonzales');
}, 10);
});
});
});
});


describe('DataTable: Basic Demo', function () {
browser.get('http://localhost:9000/demos/basic.html');

Expand All @@ -13,3 +66,9 @@ describe('DataTable: Basic Demo', function () {
});
});
});

var hasClass = function (element, cls) {
return element.getAttribute('class').then(function (classes) {
return classes.split(' ').indexOf(cls) !== -1;
});
}