blob: 46743a47053ff43e65c09eee7f2ed2caf8e17b76 (
plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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>
|