diff options
Diffstat (limited to 'vaadin-grid/test/common.js')
-rw-r--r-- | vaadin-grid/test/common.js | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/vaadin-grid/test/common.js b/vaadin-grid/test/common.js new file mode 100644 index 0000000..9c5b52a --- /dev/null +++ b/vaadin-grid/test/common.js @@ -0,0 +1,82 @@ +var grid, wrapper; + +describe.feature = function(description, suite) { + describe(description, function() { + before(function(done) { + initializeGrid(); + + waitUntil(function() { + return grid.then; + }, done, done); + }); + + after(function() { + return grid; //make sure everything is finished before moving on. + }); + + suite(); + }); +}; + +function waitUntil(check, exec, onTimeout) { + var id = setInterval(function() { + if (check()) { + clearInterval(id); + clearTimeout(timeoutId); + exec(); + } + }, 100); + + var timeoutId = setTimeout(function() { + clearInterval(id); + assert.fail(); + onTimeout(); + }, 5000); +} + + +function initializeGrid() { + wrapper = document.getElementById("gridwrapper"); + wrapper.innerHTML = "<v-grid>" + + " <table>" + + " <col header-text='Name'>" + + " <col header-text='Value'>" + + " <tbody>" + + " <tr>" + + " <td>Grid</td>" + + " <td>10000</td>" + + " </tr>" + + " <tr>" + + " <td>VaadinX</td>" + + " <td>1000</td>" + + " </tr>" + + " </tbody>" + + " <tfoot>" + + " <tr>" + + " <td>Name</td>" + + " <td>Value</td>" + + " </tr>" + + " </tfoot>"+ + " </table>" + + " </v-grid>"; + grid = wrapper.querySelector("v-grid"); + + return grid; +}; + +var local = function() { + return Polymer.dom(grid.root); +}; +var light = function() { + return Polymer.dom(grid); +}; + +var qLocal = function(selector) { + return local().querySelector(selector); +}; +var qaLocal = function(selector) { + return local().querySelectorAll(selector); +}; +var qLight = function(selector) { + return light().querySelector(selector); +}; |