Skip to content

Commit

Permalink
dom type in suites title
Browse files Browse the repository at this point in the history
getDomType in helpers.js
  • Loading branch information
programmer4web committed Jul 4, 2018
1 parent 35d7dc4 commit d333070
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 61 deletions.
10 changes: 6 additions & 4 deletions test/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
<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.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="../cosmoz-omnitable.html">
<link rel="import" href="../cosmoz-omnitable-columns.html">
<link rel="import" href="../demo/table-demo-behavior.html">

</head>
<body>
<test-fixture id="basic">
Expand Down Expand Up @@ -54,8 +55,9 @@
<script>
(function () {
'use strict';

suite('basic', function () {
// get dom Type from helpers.js
const domType = getDomType(); //eslint-disable-line no-undef
suite('basic' + domType, () => {
var omnitable,
data;

Expand Down Expand Up @@ -216,7 +218,7 @@
});
});

suite('it logs unnamed column', function () {
suite('it logs unnamed column' + domType, () => {
var omnitable,
data,
consoleErrorStub;
Expand Down
6 changes: 5 additions & 1 deletion test/boolean.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<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.js"></script>

<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
Expand All @@ -30,7 +31,10 @@
(function () {
'use strict';

suite('basic', () => {
// get dom Type from helpers.js
const domType = getDomType(); //eslint-disable-line no-undef

suite('basic' + domType, () => {
let omnitable,
column,
data;
Expand Down
9 changes: 7 additions & 2 deletions test/fit-dropdowns.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<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.js"></script>

<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
Expand Down Expand Up @@ -38,6 +39,10 @@

<script>
(function () {

// get dom Type from helpers.js
const domType = getDomType(); //eslint-disable-line no-undef

let omnitable;
const data = [
{ id: 0, group: 'group0', name: 'Item 0' },
Expand All @@ -54,7 +59,7 @@
omnitable.notifyResize();
};

suite('fit-dropdowns', function () {
suite('fit-dropdowns' + domType, () => {
test('sets iron-dropdown fitInto property', function (done) {
instantiate(function () {
[
Expand All @@ -71,7 +76,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
85 changes: 44 additions & 41 deletions test/group.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<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.js"></script>

<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
Expand Down Expand Up @@ -74,7 +75,10 @@
(function () {
'use strict';

suite('id', () => {
// get dom Type from helpers.js
const domType = getDomType(); //eslint-disable-line no-undef

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

Expand Down Expand Up @@ -130,7 +134,7 @@
});
});

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

Expand Down Expand Up @@ -170,49 +174,48 @@
}, 120);
});
});
}());

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

setup(done => {
omnitable = fixture('amount');

const onVisible = () => {
const columns = omnitable.visibleColumns;
if (Array.isArray(columns) && columns.length > 0) {
omnitable.removeEventListener('visible-columns-changed', onVisible);
Polymer.Base.async(done, 120);
}
};

data = Cosmoz.TableDemoBehavior.generateTableDemoData(10, 11, 25);
omnitable.addEventListener('visible-columns-changed', onVisible);
omnitable.data = data;
omnitable.notifyResize();
});
suite('amount' + domType, () => {
let omnitable,
data;

test('setting groupOn property to "amount" updates property groupOnColumn', done => {
omnitable.groupOn = 'amount';
setup(done => {
omnitable = fixture('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);
});
});
const onVisible = () => {
const columns = omnitable.visibleColumns;
if (Array.isArray(columns) && columns.length > 0) {
omnitable.removeEventListener('visible-columns-changed', onVisible);
Polymer.Base.async(done, 120);
}
};

data = Cosmoz.TableDemoBehavior.generateTableDemoData(10, 11, 25);
omnitable.addEventListener('visible-columns-changed', onVisible);
omnitable.data = data;
omnitable.notifyResize();
});

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>
9 changes: 7 additions & 2 deletions test/hash-param.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<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.js"></script>

<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
Expand Down Expand Up @@ -38,6 +39,10 @@

<script>
(function () {

// get dom Type from helpers.js
const domType = getDomType(); //eslint-disable-line no-undef

let omnitable;
const data = [
{ id: 0, group: 'group0', name: 'Item 0' },
Expand All @@ -55,7 +60,7 @@
omnitable.notifyResize();
};

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

suite('basic-write', function () {
suite('basic-write' + domType, () => {
setup(instantiate);
teardown(function (done) {
location.hash = '';
Expand Down
11 changes: 11 additions & 0 deletions test/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Detect dom type: dom=shadow vs wc-shadydom=true
function getDomType() { //eslint-disable-line no-unused-vars
// 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;
}
8 changes: 6 additions & 2 deletions test/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<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.js"></script>

<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
Expand Down Expand Up @@ -38,7 +39,10 @@
(function () {
'use strict';

suite('basic', () => {
// get dom Type from helpers.js
const domType = getDomType(); //eslint-disable-line no-undef

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

});
suite('horizontal', () => {
suite('horizontal' + domType, () => {
let omnitable,
column,
data;
Expand Down
11 changes: 8 additions & 3 deletions test/range-date.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<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.js"></script>

<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
Expand Down Expand Up @@ -38,6 +39,10 @@
/*global sinon chai flush */
(function () {
'use strict';

// get dom Type from helpers.js
const domType = getDomType(); //eslint-disable-line no-undef

const data = [
{ age: 17,
amount: { amount: '12.4', currency: 'USD' },
Expand Down Expand Up @@ -102,7 +107,7 @@

sinon.assert.expose(chai.assert, { prefix: '' });

suite('date', function () {
suite('date' + domType, () => {
let omnitable,
column;

Expand Down Expand Up @@ -245,7 +250,7 @@
});
});

suite('datetime', function () {
suite('datetime' + domType, () => {
let omnitable,
column;

Expand Down Expand Up @@ -342,7 +347,7 @@
});
});

suite('time', function () {
suite('time' + domType, () => {
let omnitable,
column;

Expand Down
13 changes: 9 additions & 4 deletions test/range.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<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.js"></script>

<link rel="import" href="../../test-fixture/test-fixture.html">
<link rel="import" href="../../iron-test-helpers/iron-test-helpers.html">
Expand Down Expand Up @@ -49,6 +50,10 @@
/*global sinon chai flush */
(function () {
'use strict';

// get dom Type from helpers.js
const domType = getDomType(); //eslint-disable-line no-undef

const data = [
{
age: 17,
Expand Down Expand Up @@ -82,7 +87,7 @@

sinon.assert.expose(chai.assert, { prefix: '' });

suite('number', function () {
suite('number' + domType, () => {
let omnitable,
column;

Expand Down Expand Up @@ -193,7 +198,7 @@
});
});

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

Expand Down Expand Up @@ -349,7 +354,7 @@

});

suite('currency rates', function () {
suite('currency rates', () => {
let omnitable,
column;

Expand Down Expand Up @@ -462,7 +467,7 @@
});
});

suite('default currency', function () {
suite('default currency' + domType, () => {
let omnitable,
column;

Expand Down
Loading

0 comments on commit d333070

Please sign in to comment.