Skip to content

Commit

Permalink
added test groupOn: 'amount' updates groupOnColumn
Browse files Browse the repository at this point in the history
also commented un-needed columns in the coresponding omnitable of  the suite named 'id' to speed up tests.
  • Loading branch information
programmer4web committed Jun 20, 2018
1 parent 21aa62b commit 1fc63aa
Showing 1 changed file with 56 additions and 5 deletions.
61 changes: 56 additions & 5 deletions test/group.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
<link rel="import" href="../demo/table-demo-behavior.html">
</head>
<body>
<test-fixture id="basic">
<test-fixture id="id">
<template>
<cosmoz-omnitable class="flex" group-on="id">
<cosmoz-omnitable-column title="Id" name="id" value-path="id" sort-on="id">
<template class="cell">
<a href="#!/purchase/suppliers/view?id=[[ item.id ]]">[[ item.id ]]</a>
</template>
</cosmoz-omnitable-column>
<cosmoz-omnitable-column-boolean title="Boolean" name="bool" value-path="bool" sort-on="bool" group-on="bool"
<!-- <cosmoz-omnitable-column-boolean title="Boolean" name="bool" value-path="bool" sort-on="bool" group-on="bool"
true-label="Oui" false-label="Non">
</cosmoz-omnitable-column-boolean>
<cosmoz-omnitable-column-number title="Value" name="value" value-path="value" sort-on="value">
Expand All @@ -39,7 +39,7 @@
<cosmoz-omnitable-column-date title="DateJSON" name="datejson" value-path="dateJSON" sort-on="dateJSON" group-on="dateJSON">
</cosmoz-omnitable-column-date>
<cosmoz-omnitable-column title="Sub-property" name="subproperty" value-path="sub.subProp" sort-on="sub.subProp" group-on="sub.subProp">
</cosmoz-omnitable-column>
</cosmoz-omnitable-column> -->
</cosmoz-omnitable>
</template>
</test-fixture>
Expand All @@ -61,16 +61,25 @@
</template>
</test-fixture>

<test-fixture id="amount">
<template>
<cosmoz-omnitable class="flex" group-on="amount">
<cosmoz-omnitable-column-amount title="Amount" name="amount" value-path="amount" sort-on="amount">
</cosmoz-omnitable-column-amount>
</cosmoz-omnitable>
</template>
</test-fixture>

<script>
(function () {
'use strict';

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

setup(done => {
omnitable = fixture('basic');
omnitable = fixture('id');

const onVisible = () => {
const columns = omnitable.visibleColumns;
Expand Down Expand Up @@ -163,5 +172,47 @@
});
}());

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();
});

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>

0 comments on commit 1fc63aa

Please sign in to comment.