1 |
|
2 | var tf = new TableFilter('demo', {
|
3 | base_path: '../dist/tablefilter/',
|
4 | help_instructions: {
|
5 | container_adjust_left_position: 20
|
6 | },
|
7 | responsive: true
|
8 | });
|
9 | tf.init();
|
10 |
|
11 | var help = tf.feature('help');
|
12 | module('Sanity checks');
|
13 | test('Button element', function() {
|
14 | deepEqual(typeof help, 'object', 'Help instanciated');
|
15 | notEqual(help.btn, null, 'btn property');
|
16 | });
|
17 |
|
18 | module('Pop-up container position');
|
19 | test('Help UI elements', function() {
|
20 | var container = help.cont,
|
21 | helpBtn = help.btn;
|
22 | deepEqual(container.nodeName, 'DIV', 'Help container');
|
23 | deepEqual(helpBtn.nodeName, 'SPAN', 'Help button');
|
24 | });
|
25 |
|
26 |
|
27 | test('When table has horizontal scroll', function() {
|
28 |
|
29 | tf.dom().scrollLeft = 10000;
|
30 |
|
31 |
|
32 | help.toggle();
|
33 |
|
34 |
|
35 | deepEqual(
|
36 | parseFloat(help.cont.style.left),
|
37 | (help.btn.offsetLeft
|
38 | - tf.dom().scrollLeft
|
39 | + help.contAdjustLeftPosition),
|
40 | 'Pop-up container position'
|
41 | );
|
42 | });
|
43 |
|
44 | test('When table does not have horizontal scroll', function() {
|
45 | tf.destroy();
|
46 | tf = new TableFilter('demo', {
|
47 | base_path: '../dist/tablefilter/',
|
48 | help_instructions: true,
|
49 | responsive: false
|
50 | });
|
51 | tf.init();
|
52 | var help = tf.feature('help');
|
53 |
|
54 |
|
55 | help.toggle();
|
56 |
|
57 |
|
58 | deepEqual(help.cont.style.left, '', 'Pop-up container position');
|
59 | });
|
60 |
|
61 | module('Tear-down');
|
62 | test('can destroy Help UI component', function() {
|
63 |
|
64 | tf.destroy();
|
65 | var help = tf.feature('help');
|
66 |
|
67 |
|
68 | deepEqual(help.btn, null, 'Help button removed');
|
69 | deepEqual(help.cont, null, 'Help pop-up container removed');
|
70 | });
|