mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-05-07 00:46:39 +02:00
add unit tests - prepare dist
This commit is contained in:
parent
8eddc6f35c
commit
8633891fdb
27454
dist/tablefilter/tablefilter.js
vendored
27454
dist/tablefilter/tablefilter.js
vendored
File diff suppressed because one or more lines are too long
1
dist/tablefilter/tf-1-568c8f8ffed8693fa686.js
vendored
Normal file
1
dist/tablefilter/tf-1-568c8f8ffed8693fa686.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -233,6 +233,7 @@ export class Help extends Feature {
|
||||||
+ this.contAdjustLeftPosition
|
+ this.contAdjustLeftPosition
|
||||||
}px`;
|
}px`;
|
||||||
}
|
}
|
||||||
|
|
||||||
addEvt(root, 'mouseup', this.boundMouseup);
|
addEvt(root, 'mouseup', this.boundMouseup);
|
||||||
} else {
|
} else {
|
||||||
this.cont.style.display = NONE;
|
this.cont.style.display = NONE;
|
||||||
|
|
79
test/test-help-responsive.html
Normal file
79
test/test-help-responsive.html
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>TableFilter help pop-up with responsive behaviour</title>
|
||||||
|
<link rel="stylesheet" href="libs/qunit/qunit.css">
|
||||||
|
<script src="libs/qunit/qunit.js"></script>
|
||||||
|
<script src="libs/polyfill.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style="float: right; width: 80%; border: 1px solid #f4f4f4;"></div>
|
||||||
|
<table id="demo" cellpadding="0" cellspacing="0">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th>From</th>
|
||||||
|
<th>Destination</th>
|
||||||
|
<th>Road Distance (km)</th>
|
||||||
|
<th>By Air (hrs)</th>
|
||||||
|
<th>By Rail (hrs)</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Sydney</strong></td>
|
||||||
|
<td>Adelaide</td>
|
||||||
|
<td>1412</td>
|
||||||
|
<td>1.4</td>
|
||||||
|
<td>25.3</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Sydney</strong></td>
|
||||||
|
<td>Brisbane</td>
|
||||||
|
<td>982</td>
|
||||||
|
<td>1.5</td>
|
||||||
|
<td>16</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Sydney</strong></td>
|
||||||
|
<td>Canberra</td>
|
||||||
|
<td>286</td>
|
||||||
|
<td>.6</td>
|
||||||
|
<td>4.3</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Sydney</strong></td>
|
||||||
|
<td>Melbourne</td>
|
||||||
|
<td>872</td>
|
||||||
|
<td>1.1</td>
|
||||||
|
<td>10.5</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Adelaide</strong></td>
|
||||||
|
<td>Perth</td>
|
||||||
|
<td>2781</td>
|
||||||
|
<td>3.1</td>
|
||||||
|
<td>38</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Adelaide</strong></td>
|
||||||
|
<td>Alice Springs</td>
|
||||||
|
<td>1533</td>
|
||||||
|
<td>2</td>
|
||||||
|
<td>20.25</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><strong>Adelaide</strong></td>
|
||||||
|
<td>Brisbane</td>
|
||||||
|
<td>2045</td>
|
||||||
|
<td>2.15</td>
|
||||||
|
<td>40</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<script src="../dist/tablefilter/tablefilter.js"></script>
|
||||||
|
<script src="test-help-responsive.js"></script>
|
||||||
|
|
||||||
|
<div id="qunit"></div>
|
||||||
|
<div id="qunit-fixture"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
70
test/test-help-responsive.js
Normal file
70
test/test-help-responsive.js
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
|
||||||
|
var tf = new TableFilter('demo', {
|
||||||
|
base_path: '../dist/tablefilter/',
|
||||||
|
help_instructions: {
|
||||||
|
container_adjust_left_position: 20
|
||||||
|
},
|
||||||
|
responsive: true
|
||||||
|
});
|
||||||
|
tf.init();
|
||||||
|
|
||||||
|
var help = tf.feature('help');
|
||||||
|
module('Sanity checks');
|
||||||
|
test('Button element', function() {
|
||||||
|
deepEqual(typeof help, 'object', 'Help instanciated');
|
||||||
|
notEqual(help.btn, null, 'btn property');
|
||||||
|
});
|
||||||
|
|
||||||
|
module('Pop-up container position');
|
||||||
|
test('Help UI elements', function() {
|
||||||
|
var container = help.cont,
|
||||||
|
helpBtn = help.btn;
|
||||||
|
deepEqual(container.nodeName, 'DIV', 'Help container');
|
||||||
|
deepEqual(helpBtn.nodeName, 'SPAN', 'Help button');
|
||||||
|
});
|
||||||
|
|
||||||
|
// 772 issue: pop-up container position when table feature horizontal scroll
|
||||||
|
test('When table has horizontal scroll', function() {
|
||||||
|
// setup
|
||||||
|
tf.dom().scrollLeft = 10000;
|
||||||
|
|
||||||
|
// act
|
||||||
|
help.toggle();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
deepEqual(
|
||||||
|
parseFloat(help.cont.style.left),
|
||||||
|
(help.btn.offsetLeft
|
||||||
|
- tf.dom().scrollLeft
|
||||||
|
+ help.contAdjustLeftPosition),
|
||||||
|
'Pop-up container position'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('When table does not have horizontal scroll', function() {
|
||||||
|
tf.destroy();
|
||||||
|
tf = new TableFilter('demo', {
|
||||||
|
base_path: '../dist/tablefilter/',
|
||||||
|
help_instructions: true,
|
||||||
|
responsive: false
|
||||||
|
});
|
||||||
|
tf.init();
|
||||||
|
var help = tf.feature('help');
|
||||||
|
|
||||||
|
// act
|
||||||
|
help.toggle();
|
||||||
|
|
||||||
|
// assert
|
||||||
|
deepEqual(help.cont.style.left, '', 'Pop-up container position');
|
||||||
|
});
|
||||||
|
|
||||||
|
module('Tear-down');
|
||||||
|
test('can destroy Help UI component', function() {
|
||||||
|
// act
|
||||||
|
tf.destroy();
|
||||||
|
var help = tf.feature('help');
|
||||||
|
|
||||||
|
// assert
|
||||||
|
deepEqual(help.btn, null, 'Help button removed');
|
||||||
|
deepEqual(help.cont, null, 'Help pop-up container removed');
|
||||||
|
});
|
Loading…
Reference in a new issue