1 | (function(win, TableFilter){
|
2 |
|
3 | var tf = new TableFilter('demo', {
|
4 | base_path: '../dist/tablefilter/',
|
5 | locale: 'en-GB',
|
6 | col_types: ['date', 'string']
|
7 | });
|
8 | tf.init();
|
9 |
|
10 | module('Sanity checks');
|
11 | test('TableFilter instance', function() {
|
12 | deepEqual(tf instanceof TableFilter, true, 'TableFilter type');
|
13 | });
|
14 | test('Can filter empty cells', function(){
|
15 |
|
16 | tf.setFilterValue(1, 'test');
|
17 | tf.filter();
|
18 |
|
19 | deepEqual(tf.getValidRows().length, 0, 'Expected filtered rows');
|
20 | });
|
21 | test('Can filter dd.MM.yyyy date type', function(){
|
22 |
|
23 | tf.clearFilters();
|
24 |
|
25 | tf.setFilterValue(0, '18.07.2020');
|
26 | tf.filter();
|
27 |
|
28 | deepEqual(tf.getValidRows().length, 2, 'Expected filtered rows');
|
29 | });
|
30 | test('Can clear filters', function(){
|
31 |
|
32 | tf.clearFilters();
|
33 |
|
34 | deepEqual(tf.getValidRows().length, 2167, 'Expected filtered rows');
|
35 | });
|
36 |
|
37 | module('Tear-down');
|
38 | test('Can destroy TF', function() {
|
39 |
|
40 | tf.destroy();
|
41 |
|
42 |
|
43 | deepEqual(tf.isInitialized(), false, 'Filters removed');
|
44 | });
|
45 | })(window, TableFilter);
|