Skip to content

Commit

Permalink
Merge pull request #195 from plumelo/feature/NEOV-237-tests-timezone
Browse files Browse the repository at this point in the history
Tests timezone updates. DOM type in suites title.
  • Loading branch information
nomego authored Aug 14, 2018
2 parents 4c77639 + f8a1575 commit 3a1ddae
Show file tree
Hide file tree
Showing 13 changed files with 435 additions and 369 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 9 additions & 1 deletion test/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
]
}
}
9 changes: 5 additions & 4 deletions test/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<script src="./helpers/utils.js"></script>

<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
<link rel="import" href="helpers.html">
<link rel="import" href="../cosmoz-omnitable.html">
<link rel="import" href="../cosmoz-omnitable-columns.html">
<link rel="import" href="../demo/table-demo-behavior.html">
Expand Down Expand Up @@ -53,10 +53,11 @@

<script>
(function () {
/* global setupOmnitableFixture*/
'use strict';

suite('basic', function () {
const domType = getDomType();

suite('basic' + domType, () => {
var omnitable,
data;

Expand Down Expand Up @@ -208,7 +209,7 @@
});
});

suite('it logs unnamed column', function () {
suite('it logs unnamed column' + domType, () => {
var omnitable,
data,
consoleErrorStub;
Expand Down
7 changes: 4 additions & 3 deletions test/boolean.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<script src="./helpers/utils.js"></script>

<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
<link rel="import" href="helpers.html">
<link rel="import" href="../cosmoz-omnitable.html">
<link rel="import" href="../cosmoz-omnitable-columns.html">
<link rel="import" href="../demo/table-demo-behavior.html">
Expand All @@ -28,10 +28,11 @@

<script>
(function () {
/* global setupOmnitableFixture*/
'use strict';

suite('basic', () => {
const domType = getDomType();

suite('basic' + domType, () => {
let omnitable,
column,
data;
Expand Down
13 changes: 7 additions & 6 deletions test/fit-dropdowns.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<script src="./helpers/utils.js"></script>

<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
<link rel="import" href="helpers.html">
<link rel="import" href="../cosmoz-omnitable.html">
<link rel="import" href="../cosmoz-omnitable-column-autocomplete.html">
<link rel="import" href="../cosmoz-omnitable-column.html">
Expand All @@ -35,12 +35,13 @@
</cosmoz-omnitable>
</template>
</test-fixture>

<script>
(function () {
/* global setupOmnitableFixture*/
'use strict';

let omnitable;
const data = [
const domType = getDomType(),
data = [
{ id: 0, group: 'group0', name: 'Item 0' },
{ id: 1, group: 'group0', name: 'Item 1' },
{ id: 2, group: 'group1', name: 'Item 2' },
Expand All @@ -50,7 +51,7 @@
omnitable = setupOmnitableFixture('basic', data, () => done());
};

suite('fit-dropdowns', () => {
suite('fit-dropdowns' + domType, () => {
test('sets iron-dropdown fitInto property', done => {
instantiate(() => {
[
Expand All @@ -67,7 +68,7 @@
});
});

suite('autocomplete unit tests', () => {
suite('autocomplete unit tests' + domType, () => {
test('getComparableValue returns value converted to String', done => {
instantiate(() => {
const column = omnitable.columns[0];
Expand Down
62 changes: 31 additions & 31 deletions test/group.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<script src="./helpers/utils.js"></script>

<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
<link rel="import" href="helpers.html">
<link rel="import" href="../cosmoz-omnitable.html">
<link rel="import" href="../cosmoz-omnitable-columns.html">
<link rel="import" href="../demo/table-demo-behavior.html">
Expand Down Expand Up @@ -72,10 +72,11 @@

<script>
(function () {
/* global setupOmnitableFixture*/
'use strict';

suite('id', () => {
const domType = getDomType();

suite('id' + domType, () => {
let omnitable,
data;

Expand Down Expand Up @@ -119,7 +120,7 @@
});
});

suite('bool', () => {
suite('bool' + domType, () => {
let omnitable,
data;

Expand Down Expand Up @@ -148,37 +149,36 @@
}, 120);
});
});
}());

suite('amount', () => {
let omnitable,
data;

setup(done => {
data = Cosmoz.TableDemoBehavior.generateTableDemoData(10, 11, 25);
omnitable = setupOmnitableFixture('amount', data, () => done());
});
suite('amount' + domType, () => {
let omnitable,
data;

test('setting groupOn property to "amount" updates property groupOnColumn', done => {
omnitable.groupOn = 'amount';
setup(done => {
data = Cosmoz.TableDemoBehavior.generateTableDemoData(10, 11, 25);
omnitable = setupOmnitableFixture('amount', data, () => done());
});

omnitable.notifyResize();
const verifyColumn = () => {
const groupOnColumn = omnitable.groupOnColumn;
if (groupOnColumn == null) {
Polymer.Base.async(verifyColumn, 50);
} else {
assert.equal(typeof groupOnColumn, 'object');
assert.equal(groupOnColumn.is, 'cosmoz-omnitable-column-amount');
assert.equal(groupOnColumn.name, 'amount', 'Expected "groupOnColumn" to be the column that matches "groupOn" value');
assert.equal(groupOnColumn, omnitable.columns[0]);
done();
}
};
Polymer.Base.async(verifyColumn, 50);
test('setting groupOn property to "amount" updates property groupOnColumn', done => {
omnitable.groupOn = 'amount';

omnitable.notifyResize();
const verifyColumn = () => {
const groupOnColumn = omnitable.groupOnColumn;
if (groupOnColumn == null) {
Polymer.Base.async(verifyColumn, 50);
} else {
assert.equal(typeof groupOnColumn, 'object');
assert.equal(groupOnColumn.is, 'cosmoz-omnitable-column-amount');
assert.equal(groupOnColumn.name, 'amount', 'Expected "groupOnColumn" to be the column that matches "groupOn" value');
assert.equal(groupOnColumn, omnitable.columns[0]);
done();
}
};
Polymer.Base.async(verifyColumn, 50);
});
});
});


}());
</script>
</body></html>
13 changes: 7 additions & 6 deletions test/hash-param.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<script src="./helpers/utils.js"></script>

<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
<link rel="import" href="helpers.html">

<link rel="import" href="../cosmoz-omnitable.html">
<link rel="import" href="../cosmoz-omnitable-column-autocomplete.html">
<link rel="import" href="../cosmoz-omnitable-column.html">
Expand All @@ -39,9 +38,11 @@

<script>
(function () {
/* global setupOmnitableFixture*/
'use strict';

let omnitable;
const data = [
const domType = getDomType(),
data = [
{ id: 0, group: 'group0', name: 'Item 0' },
{ id: 1, group: 'group0', name: 'Item 1' },
{ id: 2, group: 'group1', name: 'Item 2' },
Expand All @@ -52,7 +53,7 @@
omnitable = setupOmnitableFixture('basic', data, () => done());
};

suite('basic-read', function () {
suite('basic-read' + domType, () => {
teardown(function (done) {
location.hash = '';
done();
Expand Down Expand Up @@ -96,7 +97,7 @@
});
});

suite('basic-write', function () {
suite('basic-write' + domType, () => {
setup(instantiate);
teardown(function (done) {
location.hash = '';
Expand Down
30 changes: 0 additions & 30 deletions test/helpers.html

This file was deleted.

55 changes: 55 additions & 0 deletions test/helpers/utils.js
Original file line number Diff line number Diff line change
@@ -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});
}());

10 changes: 6 additions & 4 deletions test/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
<script src="../../webcomponentsjs/webcomponents-lite.js"></script>
<script src="../../web-component-tester/browser.js"></script>
<script src="../../test-fixture/test-fixture-mocha.js"></script>
<script src="./helpers/utils.js"></script>

<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
<link rel="import" href="helpers.html">
<link rel="import" href="../cosmoz-omnitable.html">
<link rel="import" href="../cosmoz-omnitable-columns.html">
<link rel="import" href="../demo/table-demo-behavior.html">
Expand All @@ -36,10 +36,12 @@

<script>
(function () {
/* global setupOmnitableFixture*/
'use strict';

suite('basic', () => {
// get dom Type from helpers.js
const domType = getDomType();

suite('basic' + domType, () => {
let omnitable,
column,
data;
Expand Down Expand Up @@ -87,7 +89,7 @@
});

});
suite('horizontal', () => {
suite('horizontal' + domType, () => {
let omnitable,
column,
data;
Expand Down
Loading

0 comments on commit 3a1ddae

Please sign in to comment.