aboutsummaryrefslogtreecommitdiffstats
path: root/vaadin-grid/test/grid-properties.html
diff options
context:
space:
mode:
Diffstat (limited to 'vaadin-grid/test/grid-properties.html')
-rw-r--r--vaadin-grid/test/grid-properties.html86
1 files changed, 86 insertions, 0 deletions
diff --git a/vaadin-grid/test/grid-properties.html b/vaadin-grid/test/grid-properties.html
new file mode 100644
index 0000000..46743a4
--- /dev/null
+++ b/vaadin-grid/test/grid-properties.html
@@ -0,0 +1,86 @@
+<!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('using properties', function() {
+
+ it('rowClassGenerator', function() {
+ var gridEquals = true;
+ var elementEquals = true;
+ assert.notOk(grid.rowClassGenerator);
+ var rowClassGenerator = function(row) {
+ gridEquals = gridEquals && row.grid == grid;
+ elementEquals = elementEquals && row.element == qaLocal(".v-grid-body .v-grid-row")[row.index];
+ return row.index + "_" + row.data[0];
+ };
+
+ grid.rowClassGenerator = rowClassGenerator;
+
+ assert.isTrue(elementEquals && gridEquals);
+ assert.isTrue(qLocal(".v-grid-body .v-grid-row").classList.contains("0_Grid"));
+ assert.equal(grid.rowClassGenerator, rowClassGenerator);
+ });
+
+ it('cellClassGenerator', function() {
+ var elementEquals = true;
+
+ grid.columns[0].name = "name";
+ grid.columns[1].name = "value";
+ assert.notOk(grid.cellClassGenerator);
+ var cellClassGenerator = function(cell) {
+ var columnIndex = cell.columnName == "name" ? 0 : 1;
+ var cellElement = qaLocal(".v-grid-body .v-grid-row")[cell.row.index].querySelectorAll(".v-grid-cell")[columnIndex];
+ elementEquals = elementEquals && cell.element == cellElement;
+ return cell.columnName;
+ };
+
+ grid.cellClassGenerator = cellClassGenerator;
+
+ assert.isTrue(elementEquals);
+ assert.isTrue(qLocal(".v-grid-body .v-grid-row .v-grid-cell").classList.contains("name"));
+ assert.equal(grid.cellClassGenerator, cellClassGenerator);
+ });
+
+ it('should be enabled by default', function() {
+ expect(grid.disabled).to.be.false;
+ });
+
+ it('should disable', function() {
+ grid.disabled = true;
+ expect(grid.disabled).to.be.true;
+ });
+
+ it('should reflect disabled to attribute', function() {
+ grid.disabled = true;
+ expect(grid.hasAttribute("disabled")).to.be.true;
+ grid.disabled = false;
+ expect(grid.hasAttribute("disabled")).to.be.false;
+ });
+
+ it('should apply disabled attribute', function() {
+ grid.setAttribute("disabled", true);
+ expect(grid.disabled).to.be.true;
+ grid.removeAttribute("disabled");
+ expect(grid.disabled).to.be.false;
+ });
+ });
+
+</script>
+
+</body>
+</html>