1 | (function(win, TableFilter){
|
2 | var tf = new TableFilter('demo', {
|
3 | base_path: '../dist/tablefilter/',
|
4 | ignore_diacritics: true
|
5 | });
|
6 | tf.init();
|
7 |
|
8 | module('Sanity checks');
|
9 | test('Enable ignore diacritics', function() {
|
10 | deepEqual(tf instanceof TableFilter, true, 'TableFilter type');
|
11 | deepEqual(tf.ignoreDiacritics, true, 'Ignore diacritics enabled');
|
12 | });
|
13 |
|
14 | module('Behaviour');
|
15 | test('Filter with `jero`', function() {
|
16 | tf.setFilterValue(1, 'jero');
|
17 | tf.filter();
|
18 | deepEqual(tf.getValidRows().length, 1, 'Expected match');
|
19 | });
|
20 |
|
21 | test('Filter with `jérô`', function() {
|
22 | tf.setFilterValue(1, 'jérô');
|
23 | tf.filter();
|
24 | deepEqual(tf.getValidRows().length, 1, 'Expected match');
|
25 | });
|
26 |
|
27 | test('Filter with `brun`', function() {
|
28 | tf.setFilterValue(1, 'brun');
|
29 | tf.filter();
|
30 | deepEqual(tf.getValidRows().length, 1, 'Expected match');
|
31 | });
|
32 |
|
33 | test('Filter with `brün`', function() {
|
34 | tf.setFilterValue(1, 'brün');
|
35 | tf.filter();
|
36 | deepEqual(tf.getValidRows().length, 1, 'Expected match');
|
37 | });
|
38 |
|
39 | test('Ignore diacritcs default', function() {
|
40 | tf.destroy();
|
41 | tf = new TableFilter('demo', {
|
42 | base_path: '../dist/tablefilter/'
|
43 | });
|
44 | tf.init();
|
45 |
|
46 | tf.setFilterValue(1, 'jero');
|
47 | tf.filter();
|
48 | deepEqual(tf.getValidRows().length, 0, '0 matches');
|
49 |
|
50 | tf.clearFilters();
|
51 | tf.setFilterValue(1, 'jérô');
|
52 | tf.filter();
|
53 | deepEqual(tf.getValidRows().length, 1, '1 matches');
|
54 | });
|
55 |
|
56 | test('Ignore diacritcs on a column basis', function() {
|
57 | tf.destroy();
|
58 | tf = new TableFilter('demo', {
|
59 | base_path: '../dist/tablefilter/',
|
60 | ignore_diacritics: [false, true, false]
|
61 | });
|
62 | tf.init();
|
63 |
|
64 | tf.setFilterValue(0, 'falo');
|
65 | tf.filter();
|
66 | deepEqual(tf.getValidRows().length, 0, 'Column: 0 - 0 matches');
|
67 |
|
68 | tf.clearFilters();
|
69 | tf.setFilterValue(0, 'falò');
|
70 | tf.filter();
|
71 | deepEqual(tf.getValidRows().length, 1, 'Column: 0 - 1 matches');
|
72 |
|
73 | tf.clearFilters();
|
74 | tf.setFilterValue(1, 'jero');
|
75 | tf.filter();
|
76 | deepEqual(tf.getValidRows().length, 1, 'Column: 1 - 1 matches');
|
77 |
|
78 | tf.clearFilters();
|
79 | tf.setFilterValue(1, 'jérô');
|
80 | tf.filter();
|
81 | deepEqual(tf.getValidRows().length, 1, 'Column: 1 - 1 matches');
|
82 | });
|
83 |
|
84 | module('Tear-down');
|
85 | test('can destroy', function() {
|
86 | tf.destroy();
|
87 | deepEqual(tf.isInitialized(), false, 'Removed');
|
88 | });
|
89 |
|
90 | })(window, TableFilter);
|