aboutsummaryrefslogtreecommitdiffstats
path: root/vaadin-grid/test/grid-binding-data.html
diff options
context:
space:
mode:
Diffstat (limited to 'vaadin-grid/test/grid-binding-data.html')
-rw-r--r--vaadin-grid/test/grid-binding-data.html185
1 files changed, 185 insertions, 0 deletions
diff --git a/vaadin-grid/test/grid-binding-data.html b/vaadin-grid/test/grid-binding-data.html
new file mode 100644
index 0000000..2d82b26
--- /dev/null
+++ b/vaadin-grid/test/grid-binding-data.html
@@ -0,0 +1,185 @@
+<!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('binding data', function() {
+
+ afterEach(function() {
+ return grid.then(function() {
+
+ grid.selection.mode = 'single';
+ grid.columns = [{name: 'Name', headerHtml: 'Name'}, {name: 'Value', headerHtml: 'Value'}];
+ grid.data.source = [['Grid', '10000'], ['VaadinX', '1000']];
+
+ return grid;
+ });
+ });
+
+ it('data: object type', function(done) {
+ grid.columns[0].name = "firstname";
+ grid.columns[1].name = "lastname";
+ grid.columns.push({
+ name: 'salary',
+ headerHtml: "Salary"
+ });
+
+ var mydata = [{
+ firstname: "John",
+ lastname: "Doe",
+ salary: 1234.56
+ }, {
+ firstname: "Jane",
+ lastname: "Doe",
+ salary: 2345.67
+ }, ];
+
+ grid.data.source = function(request) {
+ request.success(mydata.slice(request.index, request.index +
+ request.count), mydata.length);
+ };
+
+
+ waitUntil(function() {
+ return gridContainsText(grid, "2345.67");
+ }, function() {
+ var cells = qaLocal(".v-grid-body .v-grid-cell");
+ assert.equal(cells[0].innerHTML, "John");
+ assert.equal(cells[2].innerHTML, "1234.56");
+ assert.equal(cells[3].innerHTML, "Jane");
+ assert.equal(cells[4].innerHTML, "Doe");
+ done();
+ }, done);
+
+ });
+
+ it('data: array type', function(done) {
+ grid.columns.push({
+ headerHtml: "Salary"
+ });
+
+ mydata = [
+ ["John", "Doe", 1234.56],
+ ["Jane", "Doe", 2345.67],
+ ];
+
+ grid.data.source = mydata;
+
+ waitUntil(function() {
+ return gridContainsText(grid, "2345.67");
+ }, function() {
+ var cells = qaLocal(".v-grid-body .v-grid-cell");
+ assert.equal(cells[0].innerHTML, "John");
+ assert.equal(cells[2].innerHTML, "1234.56");
+ assert.equal(cells[3].innerHTML, "Jane");
+ assert.equal(cells[4].innerHTML, "Doe");
+ done();
+ }, done);
+
+ });
+
+ it('data: boolean type', function(done) {
+ grid.columns.splice(0, 1);
+ grid.selection.mode = "multi";
+
+ waitUntil(function() {
+ return qLocal("input[type='checkbox']");
+ }, function() {
+ var mydata = [
+ false,
+ true,
+ ];
+
+ grid.data.source = function(request) {
+ request.success(mydata.slice(request.index, request.index +
+ request.count), mydata.length);
+ };
+
+ waitUntil(function() {
+ return gridContainsText(grid, "false");
+ }, function() {
+ var cells = qaLocal(".v-grid-body .v-grid-cell");
+ assert.equal(cells[3].innerHTML, "true");
+ done();
+ }, done);
+ }, done);
+
+ });
+
+ it('data: string type', function(done) {
+ grid.columns.splice(0, 1);
+ grid.selection.mode = "multi";
+
+ waitUntil(function() {
+ return qLocal("input[type='checkbox']");
+ }, function() {
+ var mydata = [
+ "Lorem",
+ "Ipsum",
+ ];
+
+ grid.data.source = function(request) {
+ request.success(mydata.slice(request.index, request.index +
+ request.count), mydata.length);
+ };
+
+ waitUntil(function() {
+ return gridContainsText(grid, "Lorem");
+ }, function() {
+ var cells = qaLocal(".v-grid-body .v-grid-cell");
+ assert.equal(cells[3].innerHTML, "Ipsum");
+ done();
+ }, done);
+ }, done);
+
+ });
+
+ it('data: non-object types', function(done) {
+ var first = grid.columns[0];
+ grid.columns.splice(0, 1);
+ grid.columns.push(first);
+ grid.columns.splice(1, 1);
+ grid._grid.setRows(5);
+
+
+ var mydata = [
+ 1, 2, null, undefined, 1, "cellsready"
+ ];
+
+ grid.data.source = function(request) {
+ request.success(mydata.slice(request.index, request.index +
+ request.count), mydata.length);
+ };
+
+ waitUntil(function() {
+ return gridContainsText(grid, "cellsready");
+ }, function() {
+ var cells = qaLocal(".v-grid-body .v-grid-cell");
+ assert.equal(cells[0].innerHTML, "1");
+ assert.equal(cells[1].innerHTML, "2");
+ assert.equal(cells[2].innerHTML, "");
+ assert.equal(cells[3].innerHTML, "");
+ assert.equal(cells[4].innerHTML, "1");
+ done();
+ }, done);
+
+ });
+ });
+</script>
+
+</body>
+</html>