2015-12-21 07:25:25 +01:00
|
|
|
var tf = new TableFilter('demo', {
|
2015-12-25 03:06:54 +01:00
|
|
|
base_path: '../dist/tablefilter/',
|
2016-02-22 08:14:58 +01:00
|
|
|
col_date_type: [null, null, 'ddmmmyyyy']
|
2015-12-21 07:25:25 +01:00
|
|
|
});
|
|
|
|
tf.init();
|
|
|
|
|
|
|
|
module('Sanity checks');
|
|
|
|
test('TableFilter object', function() {
|
|
|
|
deepEqual(tf instanceof TableFilter, true, 'TableFilter instantiated');
|
|
|
|
deepEqual(tf.id, 'demo', 'id check');
|
|
|
|
deepEqual(tf.filtersRowIndex, 0, 'Filters row index');
|
|
|
|
});
|
|
|
|
|
2015-12-25 03:06:54 +01:00
|
|
|
module('Issue 74');
|
2015-12-21 07:25:25 +01:00
|
|
|
test('can filter values in this format: 21.1.18 as string', function(){
|
|
|
|
tf.setFilterValue(0, '2');
|
|
|
|
tf.filter();
|
|
|
|
deepEqual(tf.getValidRows().length, 3, 'Expected number of matches');
|
|
|
|
});
|
|
|
|
test('can filter values in this format: 21.1.18 as date', function(){
|
|
|
|
tf.clearFilters();
|
|
|
|
tf.setFilterValue(1, '21.1.2005');
|
|
|
|
tf.filter();
|
|
|
|
deepEqual(tf.getValidRows().length, 1, 'Expected number of matches');
|
|
|
|
});
|
|
|
|
test('can filter values in this format: 21.1.18 as date with operator',
|
|
|
|
function(){
|
2016-02-22 08:14:58 +01:00
|
|
|
tf.clearFilters();
|
|
|
|
tf.setFilterValue(1, '>21.1.04');
|
|
|
|
tf.filter();
|
|
|
|
deepEqual(tf.getValidRows().length, 1, 'Expected number of matches');
|
|
|
|
}
|
|
|
|
);
|
2015-12-21 07:25:25 +01:00
|
|
|
|
2015-12-25 03:06:54 +01:00
|
|
|
module('Issue 72');
|
2016-02-22 08:14:58 +01:00
|
|
|
test('can filter values in this format: 21-Jul-2010 as date', function(){
|
2015-12-25 03:06:54 +01:00
|
|
|
tf.clearFilters();
|
|
|
|
tf.setFilterValue(2, '14-Mar-2009');
|
|
|
|
tf.filter();
|
|
|
|
deepEqual(tf.getValidRows().length, 1, 'Expected number of matches');
|
|
|
|
});
|
|
|
|
test('can filter values in this format: 21-Jul-2010 as date with operator',
|
|
|
|
function(){
|
2016-02-22 08:14:58 +01:00
|
|
|
tf.clearFilters();
|
|
|
|
tf.setFilterValue(2, '<21-Jul-2010');
|
|
|
|
tf.filter();
|
|
|
|
deepEqual(tf.getValidRows().length, 2, 'Expected number of matches');
|
|
|
|
}
|
|
|
|
);
|
2015-12-25 03:06:54 +01:00
|
|
|
|
2015-12-21 07:25:25 +01:00
|
|
|
module('Tear-down');
|
|
|
|
test('can destroy TableFilter DOM elements', function() {
|
|
|
|
tf.destroy();
|
|
|
|
deepEqual(tf.hasGrid(), false, 'Filters removed');
|
|
|
|
});
|