1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-17 05:46:39 +02:00

Upadated unit tests

This commit is contained in:
Max Guglielmi 2016-04-20 16:03:35 +02:00
parent f3760a0dcd
commit 16d221913d
3 changed files with 44 additions and 61 deletions

View file

@ -1121,19 +1121,19 @@ webpackJsonp([1],{
if (!this.manager) {
return;
}
this.buildBtn();
this.buildManager();
this.initialized = true;
this.emitter.on(['hide-column'], function (tf, colIndex) {
return _this.hideCol(colIndex);
});
this.buildBtn();
this.buildManager();
this.initialized = true;
this.emitter.emit('columns-visibility-initialized', tf, this);
// Hide columns at start at very end of initialization
// TODO: re-evaluate this as conceptually wrong
this.hideAtStart();
this._hideAtStart();
};
/**
@ -1294,17 +1294,6 @@ webpackJsonp([1],{
this.btnEl.parentNode.insertBefore(container, this.btnEl);
this.contEl = container;
// if (this.atStart) {
// let a = this.atStart;
// for (let k = 0; k < a.length; k++) {
// // let itm = Dom.id('col_' + a[k] + '_' + tf.id);
// // if (itm) {
// // itm.click();
// // }
// this.hideCol(a[k]);
// }
// }
};
/**
@ -1463,21 +1452,6 @@ webpackJsonp([1],{
return this.hiddenCols;
};
/**
* Hide columns at start
*/
ColsVisibility.prototype.hideAtStart = function hideAtStart() {
if (!this.atStart) {
return;
}
var a = this.atStart;
for (var k = 0; k < a.length; k++) {
this.hideCol(a[k]);
}
};
/**
* Remove the columns manager
*/
@ -1538,6 +1512,17 @@ webpackJsonp([1],{
}
};
ColsVisibility.prototype._hideAtStart = function _hideAtStart() {
var _this5 = this;
if (!this.atStart) {
return;
}
this.atStart.forEach(function (colIdx) {
_this5.hideCol(colIdx);
});
};
return ColsVisibility;
}();

View file

@ -174,18 +174,18 @@ export default class ColsVisibility {
if (!this.manager) {
return;
}
this.emitter.on(['hide-column'],
(tf, colIndex) => this.hideCol(colIndex));
this.buildBtn();
this.buildManager();
this.initialized = true;
this.emitter.on(['hide-column'],
(tf, colIndex) => this.hideCol(colIndex));
this.emitter.emit('columns-visibility-initialized', tf, this);
// Hide columns at start at very end of initialization
// TODO: re-evaluate this as conceptually wrong
this.hideAtStart();
this._hideAtStart();
}
/**
@ -329,17 +329,6 @@ export default class ColsVisibility {
this.btnEl.parentNode.insertBefore(container, this.btnEl);
this.contEl = container;
// if (this.atStart) {
// let a = this.atStart;
// for (let k = 0; k < a.length; k++) {
// // let itm = Dom.id('col_' + a[k] + '_' + tf.id);
// // if (itm) {
// // itm.click();
// // }
// this.hideCol(a[k]);
// }
// }
}
/**
@ -490,19 +479,6 @@ export default class ColsVisibility {
return this.hiddenCols;
}
/**
* Hide columns at start
*/
hideAtStart() {
if (!this.atStart) {
return;
}
let a = this.atStart;
for (let k = 0; k < a.length; k++) {
this.hideCol(a[k]);
}
}
/**
* Remove the columns manager
*/
@ -558,4 +534,12 @@ export default class ColsVisibility {
}
}
_hideAtStart() {
if (!this.atStart) {
return;
}
this.atStart.forEach((colIdx) => {
this.hideCol(colIdx);
});
}
}

View file

@ -119,6 +119,20 @@ test('Can update sort', function() {
{ 'sort': { 'descending': true } }, 'Sort updated');
});
test('Can update columns visibility', function() {
// setup
state.persistColsVisibility = true;
state.state = {};
// act
state.updateColsVisibility([0, 2]);
state.persistColsVisibility = false;
// assert
deepEqual(state.state.col_0.hidden, true, 'Column 0 visibility updated');
deepEqual(state.state.col_2.hidden, true, 'Column 2 visibility updated');
});
module('Tear-down');
test('Can destroy TF', function() {
// setup