1 | var tf = new TableFilter('demo', {
|
2 | base_path: '../dist/tablefilter/'
|
3 | });
|
4 | tf.init();
|
5 |
|
6 | module('filtering');
|
7 | test('ignore uneven rows', function() {
|
8 |
|
9 | tf.setFilterValue(1, 'Perth');
|
10 | tf.filter();
|
11 |
|
12 |
|
13 | deepEqual(tf.getValidRows(), [9], 'uneven row');
|
14 | deepEqual(tf.getRowDisplay(tf.dom().rows[4]), '', 'uneven row displayed');
|
15 | deepEqual(tf.getRowDisplay(tf.dom().rows[5]), '', 'uneven row displayed');
|
16 | deepEqual(tf.getRowDisplay(tf.dom().rows[5]), '', 'uneven row displayed');
|
17 | });
|
18 |
|
19 | test('display uneven rows when no matches', function() {
|
20 |
|
21 | tf.clearFilters();
|
22 | tf.setFilterValue(0, '123');
|
23 | tf.filter();
|
24 |
|
25 |
|
26 | deepEqual(tf.getValidRows(), [], 'uneven row');
|
27 | deepEqual(tf.getRowDisplay(tf.dom().rows[4]), '', 'uneven row displayed');
|
28 | deepEqual(tf.getRowDisplay(tf.dom().rows[5]), '', 'uneven row displayed');
|
29 | deepEqual(tf.getRowDisplay(tf.dom().rows[5]), '', 'uneven row displayed');
|
30 | });
|
31 |
|
32 | module('re-initialise');
|
33 | test('can re-initialise', function() {
|
34 |
|
35 | tf.destroy();
|
36 | tf.init();
|
37 |
|
38 |
|
39 | deepEqual(tf.isInitialized(), true, 'Filters re-initialised');
|
40 | });
|
41 |
|
42 | test('can filter', function() {
|
43 |
|
44 | tf.setFilterValue(1, 'Perth');
|
45 | tf.filter();
|
46 |
|
47 |
|
48 | deepEqual(tf.getValidRows(), [9], 'uneven row');
|
49 | deepEqual(tf.getRowDisplay(tf.dom().rows[4]), '', 'uneven row displayed');
|
50 | deepEqual(tf.getRowDisplay(tf.dom().rows[5]), '', 'uneven row displayed');
|
51 | deepEqual(tf.getRowDisplay(tf.dom().rows[5]), '', 'uneven row displayed');
|
52 | });
|
53 |
|
54 | module('tear-down');
|
55 | test('can destroy', function() {
|
56 |
|
57 | tf.destroy();
|
58 |
|
59 |
|
60 | deepEqual(tf.isInitialized(), false, 'Filters removed');
|
61 | });
|