1 | (function(win, TableFilter){
|
2 | var tf = new TableFilter('demo', {
|
3 | base_path: '../dist/tablefilter/',
|
4 | exact_match: true
|
5 | });
|
6 | tf.init();
|
7 |
|
8 | module('Sanity checks');
|
9 | test('Enable exact query match', function() {
|
10 | deepEqual(tf instanceof TableFilter, true, 'TableFilter type');
|
11 | deepEqual(tf.exactMatch, true, 'Exact query match enabled');
|
12 | });
|
13 |
|
14 | module('Behaviour');
|
15 | test('After filtering with `syd`', function() {
|
16 | tf.setFilterValue(0, 'syd');
|
17 | tf.filter();
|
18 | deepEqual(tf.getValidRows().length, 0, 'No matches');
|
19 | });
|
20 |
|
21 | test('After filtering with `sydney`', function() {
|
22 | tf.setFilterValue(0, 'sydney');
|
23 | tf.filter();
|
24 | deepEqual(tf.getValidRows().length>0, true, 'Matches');
|
25 | });
|
26 |
|
27 | module('Re-instantiate with exact match by column');
|
28 | test('Enable extact query match by column', function() {
|
29 | tf.destroy();
|
30 | tf = null;
|
31 | tf = new TableFilter('demo', {
|
32 | base_path: '../dist/tablefilter/',
|
33 | columns_exact_match: [true, true, false, false, false]
|
34 | });
|
35 | tf.init();
|
36 |
|
37 | deepEqual(tf instanceof TableFilter, true, 'TableFilter type');
|
38 | deepEqual(tf.hasExactMatchByCol, true,
|
39 | 'Exact query match by column enabled');
|
40 | });
|
41 | module('Behaviour with exact match by column');
|
42 | test('After filtering with `syd`', function() {
|
43 | tf.setFilterValue(0, 'syd');
|
44 | tf.setFilterValue(1, 'bris');
|
45 | tf.filter();
|
46 | deepEqual(tf.getValidRows().length, 0, 'No matches');
|
47 | });
|
48 |
|
49 | test('After filtering with `sydney`', function() {
|
50 | tf.clearFilters();
|
51 | tf.setFilterValue(0, 'sydney');
|
52 | tf.filter();
|
53 | deepEqual(tf.getValidRows().length>0, true, 'Matches');
|
54 | });
|
55 |
|
56 | })(window, TableFilter);
|