diff --git a/package.json b/package.json index 918ab581..4050f5e3 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "start": "polymer serve -o", "postinstall": "polymer install --variants", "lint": "eslint --cache --ext .js,.html . && polymer lint cosmoz-*.html", - "test": "TZ=Europe/Bucharest polymer test", + "test": "polymer test", "analyze": "polymer analyze --input cosmoz-*.html > analysis.json" }, "repository": { diff --git a/test/.eslintrc.json b/test/.eslintrc.json index 328c2ce3..1f335c91 100644 --- a/test/.eslintrc.json +++ b/test/.eslintrc.json @@ -12,6 +12,14 @@ "flush": false, "MockInteractions": false, "sinon": true, - "WCT": false + "WCT": false, + "getDomType": false, + "setupOmnitableFixture":false + }, + "rules": { + "no-unused-vars": [ + "warn", + {"varsIgnorePattern":"omnitable"} + ] } } diff --git a/test/basic.html b/test/basic.html index 6c1b19b7..dbea4877 100644 --- a/test/basic.html +++ b/test/basic.html @@ -8,10 +8,10 @@ + - @@ -53,10 +53,11 @@ + - @@ -28,10 +28,11 @@ + - @@ -35,12 +35,13 @@ - + - @@ -72,10 +72,11 @@ diff --git a/test/hash-param.html b/test/hash-param.html index 6319956f..74ff7624 100644 --- a/test/hash-param.html +++ b/test/hash-param.html @@ -8,11 +8,10 @@ + - - @@ -39,9 +38,11 @@ diff --git a/test/helpers/utils.js b/test/helpers/utils.js new file mode 100644 index 00000000..bc008fb8 --- /dev/null +++ b/test/helpers/utils.js @@ -0,0 +1,55 @@ +(function () { + 'use strict'; + + const setupOmnitableFixture = (omnitableFixtureName, data, callback) => { + const omnitable = fixture(omnitableFixtureName); + omnitable.data = data; + if (omnitable.visibleColumns != null && omnitable.visibleColumns.length) { + callback(omnitable); + } else { + // In Polymer 1.x, the visible-columns-changed event will be fire multiple times, + // causing done to be called multiple times, which mocha does not allow. + // So using a flag to prevent multiple calls to done. + const onVisible = () => { + const columns = omnitable.visibleColumns; + if (Array.isArray(columns) && columns.length > 0) { + omnitable.removeEventListener('visible-columns-changed', onVisible); + Polymer.Base.async(() => callback(omnitable), 60); + } + }; + + omnitable.addEventListener('visible-columns-changed', onVisible); + } + + omnitable.notifyResize(); + return omnitable; + }; + + // Detect dom type: dom=shadow vs wc-shadydom=true + const getDomType = () => { + // match GET parameter named 'dom' + let param = window.location.search.match(/(\?|&)dom\=([^&]*)/), // eslint-disable-line no-useless-escape + dom; + if (Array.isArray(param) && param.length > 0) { + dom = decodeURIComponent(param[2]); + } + const domType = dom && dom === 'shadow' ? ' | Using shadow DOM' : ' | Using shady DOM'; + return domType; + }; + + const onColumnReady = (omnitable, columnIndex, done) => { + const checkReady = () => { + const {visibleColumns: visible, columns} = omnitable; + if (visible && visible.length > 0) { + omnitable.removeEventListener('visible-columns-changed', checkReady); + Polymer.Base.async(() => done(columns[columnIndex]), 30); + } + }; + omnitable.addEventListener('visible-columns-changed', checkReady); + omnitable.notifyResize(); + checkReady(); + }; + + Object.assign(window, {setupOmnitableFixture, getDomType, onColumnReady}); +}()); + diff --git a/test/list.html b/test/list.html index 6a85b3cc..a03c8156 100644 --- a/test/list.html +++ b/test/list.html @@ -8,10 +8,10 @@ + - @@ -36,10 +36,12 @@ + - @@ -35,42 +35,62 @@ + - @@ -46,43 +46,44 @@ + - @@ -49,31 +49,29 @@