aboutsummaryrefslogtreecommitdiffstats
path: root/vaadin-grid/test/grid-sorting-rows.html
diff options
context:
space:
mode:
Diffstat (limited to 'vaadin-grid/test/grid-sorting-rows.html')
-rw-r--r--vaadin-grid/test/grid-sorting-rows.html100
1 files changed, 100 insertions, 0 deletions
diff --git a/vaadin-grid/test/grid-sorting-rows.html b/vaadin-grid/test/grid-sorting-rows.html
new file mode 100644
index 0000000..59acbbf
--- /dev/null
+++ b/vaadin-grid/test/grid-sorting-rows.html
@@ -0,0 +1,100 @@
+<!DOCTYPE html>
+<html>
+
+<head lang="en">
+ <meta charset="UTF-8">
+ <title></title>
+
+ <script src="../../webcomponentsjs/webcomponents-lite.min.js"></script>
+ <script src="../../web-component-tester/browser.js"></script>
+ <script src="common.js"></script>
+
+ <link rel="import" href="../vaadin-grid.html">
+</head>
+
+<body>
+
+ <div id="gridwrapper"></div>
+
+ <script>
+ describe.feature('sorting rows', function() {
+
+ describe('using api', function() {
+
+ function assignInvalidSortOrder() {
+ grid.data.sortOrder = [{
+ column: 0,
+ direction: "ascending" // Should be asc or desc
+ }];
+ }
+
+ beforeEach(function() {
+ grid.columns[0].sortable = true;
+ grid.columns[1].sortable = true;
+ });
+
+ it('should set sortOrder property', function() {
+ grid.data.sortOrder = [{
+ column: 0,
+ direction: "desc"
+ }];
+
+ expect(qLocal(".v-grid-header th").classList.contains("sort-desc")).to.be.true;
+ });
+
+ it('should clear sort order', function() {
+ grid.data.sortOrder = [{
+ column: 0,
+ direction: "desc"
+ }];
+ grid.data.sortOrder = [];
+ expect(grid.data.sortOrder).to.be.empty;
+ });
+
+ it('should preserve existing sort order on invalid value', function() {
+ grid.data.sortOrder = [{
+ column: 0,
+ direction: "desc"
+ }];
+ expect(assignInvalidSortOrder).to.throw("Invalid sort direction");
+ expect(qLocal(".v-grid-header th").classList.contains("sort-desc")).to.be.true;
+ });
+
+ it('should be able to sort with multiple columns', function() {
+ grid.data.sortOrder = [{
+ column: 0,
+ direction: "desc"
+ }, {
+ column: 1
+ }];
+ assert.lengthOf(grid.data.sortOrder, 2);
+ expect(qaLocal(".v-grid-header th")[0].classList.contains("sort-desc")).to.be.true;
+ expect(qaLocal(".v-grid-header th")[1].classList.contains("sort-asc")).to.be.true;
+ });
+
+ it('should reset selection', function() {
+ grid.selectedRows = [0];
+
+ grid.data.sortOrder = [{
+ column: 0,
+ direction: "desc"
+ }];
+
+ expect(grid.selection.selected()).to.be.empty;
+ });
+
+ it('should ignore selection column from index', function() {
+ var firstNonFrozenHeaderCell = qLocal.bind(this, ".v-grid-header .v-grid-cell:not(.frozen)");
+
+ firstNonFrozenHeaderCell().click();
+ expect(grid.data.sortOrder[0].column).to.eql(0);
+
+ grid.selection.mode = "multi";
+ firstNonFrozenHeaderCell().click();
+ expect(grid.data.sortOrder[0].column).to.eql(0);
+ });
+
+
+ });
+ });
+ </script>