mirror of
https://github.com/koalyptus/TableFilter.git
synced 2026-03-16 23:55:46 +01:00
Added col widths tests
This commit is contained in:
parent
aeb94da59a
commit
ec79d1410a
8 changed files with 236 additions and 152 deletions
79
test/test-col-widths.html
Normal file
79
test/test-col-widths.html
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>TableFilter column widths tests</title>
|
||||
<link rel="stylesheet" href="libs/qunit/qunit.css">
|
||||
<script src="libs/qunit/qunit.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<table id="demo">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>From</th>
|
||||
<th>Destination</th>
|
||||
<th>Road Distance (km)</th>
|
||||
<th>By Air (hrs)</th>
|
||||
<th>By Rail (hrs)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<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-col-widths.js"></script>
|
||||
|
||||
<div id="qunit"></div>
|
||||
<div id="qunit-fixture"></div>
|
||||
</body>
|
||||
</html>
|
||||
36
test/test-col-widths.js
Normal file
36
test/test-col-widths.js
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
|
||||
(function(win, TableFilter){
|
||||
var id = function (id){ return document.getElementById(id); };
|
||||
|
||||
var tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
col_widths: ['150px', '100px', '175px', '120px', null]
|
||||
});
|
||||
tf.init();
|
||||
|
||||
module('Sanity checks');
|
||||
test('Column widths', function() {
|
||||
var filterRow = tf.tbl.rows[tf.getFiltersRowIndex()];
|
||||
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
|
||||
deepEqual(filterRow.cells[1].style.width,
|
||||
'100px', 'Expected column width');
|
||||
deepEqual(filterRow.cells[4].style.width, '', 'Expected column width');
|
||||
});
|
||||
|
||||
test('Grid layout column widths', function() {
|
||||
tf.destroy();
|
||||
tf = null;
|
||||
tf = new TableFilter('demo', {
|
||||
base_path: '../dist/tablefilter/',
|
||||
col_widths: ['150px', '100px', '175px', '120px', '200px'],
|
||||
grid_layout: true,
|
||||
sort: false
|
||||
});
|
||||
tf.init();
|
||||
deepEqual(tf.getHeaderElement(0).style.width,
|
||||
'150px', 'Expected column width');
|
||||
deepEqual(tf.getHeaderElement(4).style.width,
|
||||
'200px', 'Expected column width');
|
||||
});
|
||||
|
||||
})(window, TableFilter);
|
||||
Loading…
Add table
Add a link
Reference in a new issue