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

26 lines
800 B
JavaScript
Raw Normal View History

2014-11-15 09:39:10 +01:00
2015-05-10 13:12:31 +02:00
var id = function (id){ return document.getElementById(id); };
var table = document.getElementById('demo');
var totRowIndex = table.getElementsByTagName('tr').length;
2014-11-15 09:39:10 +01:00
2015-05-10 13:12:31 +02:00
var tf = new TableFilter('demo', {
rows_always_visible: [totRowIndex],
col_operation: {
id: ['sum1', 'sum2'],
col: [2, 3],
operation: ['sum', 'mean'],
write_method: ['innerhtml', 'innerhtml'],
exclude_row: [totRowIndex],
decimal_precision: [0, 2],
tot_row_index: [totRowIndex, totRowIndex]
}
});
tf.init();
2014-11-15 09:39:10 +01:00
2015-05-10 13:12:31 +02:00
module('Sanity checks');
test('Column Operations component', function() {
deepEqual(typeof tf.Cpt.colOps, 'object', 'ColOps instanciated');
equal(id('sum1').innerHTML, 9911, 'Sum result');
equal(id('sum2').innerHTML, 1.69, 'Mean result');
});