mirror of
https://github.com/koalyptus/TableFilter.git
synced 2024-06-16 12:45:49 +02:00
Added popup filter tests
This commit is contained in:
parent
4d34104a4e
commit
31b7f18c9e
82
test/test-popup-filter.html
Normal file
82
test/test-popup-filter.html
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>TableFilter pop-up filter</title>
|
||||||
|
<link rel="stylesheet" href="libs/qunit/qunit.css">
|
||||||
|
<link rel="stylesheet" href="../dist/filtergrid.css">
|
||||||
|
<script src="libs/qunit/qunit.js"></script>
|
||||||
|
<script>
|
||||||
|
// Defer Qunit so RequireJS can work its magic and resolve all modules.
|
||||||
|
QUnit.config.autostart = false;
|
||||||
|
QUnit.config.autoload = false;
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<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 data-main="test-popup-filter" src="../libs/requirejs/require.js"></script>
|
||||||
|
|
||||||
|
<div id="qunit"></div>
|
||||||
|
<div id="qunit-fixture"></div>
|
||||||
|
</body>
|
||||||
|
</html>
|
51
test/test-popup-filter.js
Normal file
51
test/test-popup-filter.js
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
requirejs(['test-config', '../src/core'], function(config, TableFilter){
|
||||||
|
|
||||||
|
QUnit.start();
|
||||||
|
|
||||||
|
var PopupFilter = require('modules/popupFilter').PopupFilter,
|
||||||
|
types = require('types').Types,
|
||||||
|
dom = require('dom').Dom;
|
||||||
|
|
||||||
|
var tf = new TableFilter('demo', {
|
||||||
|
col_2: 'multiple',
|
||||||
|
col_3: 'select',
|
||||||
|
popup_filters: true
|
||||||
|
});
|
||||||
|
tf.init();
|
||||||
|
|
||||||
|
var popupFilter = tf.Cpt.popupFilter;
|
||||||
|
module('Sanity checks');
|
||||||
|
test('Pop-up filter component', function() {
|
||||||
|
deepEqual(popupFilter instanceof PopupFilter, true, 'PopupFilter type');
|
||||||
|
notEqual(popupFilter, null, 'PopupFilter instanciated');
|
||||||
|
deepEqual(types.isArray(popupFilter.popUpFltElms), true, 'Type of popUpFltElms property');
|
||||||
|
});
|
||||||
|
|
||||||
|
module('UI elements');
|
||||||
|
test('Pop-up filter UI elements', function() {
|
||||||
|
var flt1 = dom.id(tf.fltIds[3]);
|
||||||
|
var flt2 = dom.id(tf.fltIds[2]);
|
||||||
|
var fltIcn1 = tf.Cpt.popupFilter.popUpFltImgs[3];
|
||||||
|
var fltIcn2 = tf.Cpt.popupFilter.popUpFltImgs[2];
|
||||||
|
notEqual(flt1, null, 'Filter element exists');
|
||||||
|
notEqual(flt2, null, 'Filter element exists');
|
||||||
|
deepEqual(flt2.hasAttribute('multiple'), true, 'Multiple select exists');
|
||||||
|
deepEqual(fltIcn1.nodeName, 'IMG', 'Filter icon exists');
|
||||||
|
deepEqual(fltIcn2.nodeName, 'IMG', 'Filter icon exists');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('TableFilter removed', function() {
|
||||||
|
tf.RemoveGrid();
|
||||||
|
var fltIcn1 = tf.Cpt.popupFilter.popUpFltImgs[3];
|
||||||
|
deepEqual(fltIcn1, undefined, 'Filter icon is removed');
|
||||||
|
deepEqual(dom.id(tf.fltIds[3]), null, 'Filter is removed');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('TableFilter re-initialised', function() {
|
||||||
|
tf.init();
|
||||||
|
var fltIcn1 = tf.Cpt.popupFilter.popUpFltImgs[3];
|
||||||
|
deepEqual(fltIcn1.nodeName, 'IMG', 'Filter icon exists');
|
||||||
|
deepEqual(dom.id(tf.fltIds[3]).nodeName, 'SELECT', 'Filter exists');
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
Reference in a new issue