1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-17 22:06:41 +02:00
TableFilter/test/test-checklist.js

43 lines
1.3 KiB
JavaScript
Raw Normal View History

2015-02-01 09:26:48 +01:00
2015-05-10 13:12:31 +02:00
var id = function (id){ return document.getElementById(id); };
var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
2015-05-10 13:12:31 +02:00
col_3: 'checklist',
load_filters_on_demand: false
2015-05-10 13:12:31 +02:00
});
tf.init();
2015-02-01 09:26:48 +01:00
var checkList = tf.feature('checkList');
2015-05-10 13:12:31 +02:00
module('Sanity checks');
test('CheckList component', function() {
deepEqual(typeof checkList, 'object', 'CheckList instanciated');
deepEqual(checkList.checkListDiv instanceof Array, true, 'Type of checkListDiv property');
});
2015-02-01 09:26:48 +01:00
2015-05-10 13:12:31 +02:00
module('UI elements');
test('CheckList UI elements', function() {
var flt = id(tf.fltIds[3]);
notEqual(flt, null, 'CheckList UL element');
deepEqual(flt.firstChild.nodeName, 'LI', 'First CheckList option element name');
deepEqual(flt.childNodes.length, 8, 'number of checklist options');
2015-05-10 13:12:31 +02:00
});
2015-02-01 09:26:48 +01:00
2016-01-09 10:22:57 +01:00
module('Behaviour');
test('Can filter on checkList change', function() {
var flt1 = id(tf.fltIds[3]);
var evObj = document.createEvent('HTMLEvents');
evObj.initEvent('change', true, true);
tf.activeFlt = flt1;
tf.setFilterValue(3, '1.1');
flt1.dispatchEvent(evObj);
deepEqual(tf.getValidRows().length, 1, 'Table filtered');
deepEqual(tf.getFilteredData()[0][1][3], '1.1', 'Matched value');
});
2015-05-10 13:12:31 +02:00
test('TableFilter removed', function() {
tf.destroy();
2015-05-10 13:12:31 +02:00
deepEqual(id(tf.fltIds[3]), null, 'CheckList UL element');
2015-02-01 09:26:48 +01:00
});