1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2026-03-18 00:19:50 +01:00

Removed external_flt_grid_option setting, make paths properties functions

This commit is contained in:
koalyptus 2017-07-16 10:52:40 +10:00
commit f2242c4e57
25 changed files with 232 additions and 64 deletions

View file

@ -7,7 +7,6 @@ var tf = new TableFilter('demo', {
col_3: 'multiple',
col_4: 'checklist',
/* external filters */
external_flt_grid: true,
external_flt_grid_ids: [
'extFrom',
'extDestination',
@ -21,7 +20,7 @@ tf.init();
module('Sanity checks');
test('External filters', function() {
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.isExternalFlt, true, 'Has external filters');
deepEqual(tf.isExternalFlt(), true, 'Has external filters');
deepEqual(tf.externalFltTgtIds.length, 5,
'External filters ids length');
deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index');
@ -82,7 +81,6 @@ test('Sanity checks', function() {
col_3: 'multiple',
col_4: 'checklist',
/* external filters */
external_flt_grid: true,
external_flt_grid_ids: [
'extFrom',
'extDestination',
@ -95,7 +93,7 @@ test('Sanity checks', function() {
tf.init();
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.isExternalFlt, true, 'Has external filters');
deepEqual(tf.isExternalFlt(), true, 'Has external filters');
deepEqual(tf.externalFltTgtIds.length, 5,
'External filters ids length');
deepEqual(tf.getFiltersRowIndex(), 1, 'Filters row index');
@ -154,7 +152,6 @@ test('Sanity checks', function() {
col_3: 'multiple',
col_4: 'checklist',
/* external filters */
external_flt_grid: true,
external_flt_grid_ids: [
'extFrom',
'extDestination',
@ -167,7 +164,7 @@ test('Sanity checks', function() {
tf.init();
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.isExternalFlt, true, 'Has external filters');
deepEqual(tf.isExternalFlt(), true, 'Has external filters');
deepEqual(tf.externalFltTgtIds.length, 5,
'External filters ids length');
deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index');

80
test/test-no-config.html Normal file
View file

@ -0,0 +1,80 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>TableFilter no configuration tests</title>
<link rel="stylesheet" href="libs/qunit/qunit.css">
<script src="libs/qunit/qunit.js"></script>
<script src="libs/polyfill.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-no-config.js"></script>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>

63
test/test-no-config.js Normal file
View file

@ -0,0 +1,63 @@
(function(win, TableFilter){
var tf = new TableFilter('demo');
tf.basePath = '../dist/tablefilter/';
tf.init();
module('Sanity checks');
test('Features', function() {
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
deepEqual(tf.fltGrid, true, 'fltGrid property');
notEqual(tf.getFilterElement(0), null,
'Filter element for column 0');
deepEqual(tf.refRow, 2, 'Reference row index');
deepEqual(Object.keys(tf.Mod).length, 14, 'Features instantiated');
notEqual(tf.feature('rowsCounter'), null, 'RowsCounter instantiated');
deepEqual(tf.rowsCounter, false, 'RowsCounter not enabled');
});
module('Feature life cycle');
test('Can init', function() {
// setup
var rowsCounter = tf.feature('rowsCounter');
tf.rowsCounter = true;
rowsCounter.enable();
// act
rowsCounter.init();
// assert
deepEqual(rowsCounter.enabled, true, 'rowsCounter enabled');
deepEqual(rowsCounter.initialized, true, 'rowsCounter initialized');
});
test('Can destroy', function() {
// setup
var rowsCounter = tf.feature('rowsCounter');
// act
rowsCounter.destroy();
// assert
deepEqual(rowsCounter.initialized, false, 'rowsCounter initialized');
});
test('Can reset', function() {
// setup
var rowsCounter = tf.feature('rowsCounter');
// act
rowsCounter.reset();
// assert
deepEqual(rowsCounter.enabled, true, 'rowsCounter enabled');
deepEqual(rowsCounter.initialized, true, 'rowsCounter initialized');
});
module('Tear-down');
test('TableFilter removed', function() {
tf.destroy();
deepEqual(tf.isInitialized(), false, 'Filters removed');
});
})(window, TableFilter);

View file

@ -27,7 +27,6 @@ test('Sanity checks', function() {
tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
single_filter: true,
external_flt_grid: true,
external_flt_grid_ids: ['single-search']
});
tf.init();