mirror of
https://github.com/koalyptus/TableFilter.git
synced 2026-03-17 16:10:04 +01:00
Initial commit
This commit is contained in:
parent
fe0a4d7fd7
commit
dcb271e0ba
41 changed files with 9616 additions and 653 deletions
|
|
@ -14,6 +14,49 @@ test('AlternateRows component', function() {
|
|||
deepEqual(altRows.oddCss, 'odd', 'Expected odd css class');
|
||||
});
|
||||
|
||||
module('Feature interface');
|
||||
test('Properties', function() {
|
||||
deepEqual(
|
||||
altRows.tf instanceof TableFilter, true, 'TableFilter instance');
|
||||
deepEqual(altRows.feature, 'alternateRows', 'Feature name');
|
||||
deepEqual(altRows.enabled, true, 'Feature enabled');
|
||||
deepEqual(altRows.initialized, true, 'Feature enabled');
|
||||
deepEqual(typeof altRows.config, 'object', 'TF configuration object');
|
||||
deepEqual(typeof altRows.init, 'function', 'Feature init method');
|
||||
deepEqual(typeof altRows.destroy, 'function', 'Feature destroy method');
|
||||
deepEqual(typeof altRows.reset, 'function', 'Feature reset method');
|
||||
deepEqual(typeof altRows.enable, 'function', 'Feature enable method');
|
||||
deepEqual(typeof altRows.disable, 'function', 'Feature enable method');
|
||||
deepEqual(
|
||||
typeof altRows.isEnabled, 'function', 'Feature enable method');
|
||||
});
|
||||
test('Can destroy', function() {
|
||||
altRows.destroy();
|
||||
deepEqual(altRows.enabled, false, 'disabled');
|
||||
});
|
||||
test('Can reset', function() {
|
||||
altRows.reset();
|
||||
deepEqual(altRows.enabled, true, 'enabled');
|
||||
});
|
||||
test('Can disable', function() {
|
||||
altRows.disable();
|
||||
deepEqual(altRows.enabled, false, 'disabled');
|
||||
});
|
||||
test('Can enable', function() {
|
||||
altRows.enable();
|
||||
deepEqual(altRows.enabled, true, 'enabled');
|
||||
});
|
||||
test('Can init', function() {
|
||||
altRows.destroy();
|
||||
altRows.enable();
|
||||
altRows.init();
|
||||
deepEqual(altRows.enabled, true, 'enabled');
|
||||
});
|
||||
test('Can check is enabled', function() {
|
||||
altRows.isEnabled();
|
||||
deepEqual(altRows.enabled, true, 'enabled');
|
||||
});
|
||||
|
||||
module('Actions');
|
||||
test('Filter column', function() {
|
||||
tf.setFilterValue(2, '>1400');
|
||||
|
|
@ -31,12 +74,6 @@ test('Clear filters', function() {
|
|||
deepEqual(tbl.querySelectorAll('tr.even').length, 4, 'Even bg removed');
|
||||
});
|
||||
|
||||
test('Remove alternating rows', function() {
|
||||
altRows.remove();
|
||||
deepEqual(tbl.querySelectorAll('tr.odd').length, 0, 'Odd bgs removed');
|
||||
deepEqual(tbl.querySelectorAll('tr.even').length, 0, 'Even bg removed');
|
||||
});
|
||||
|
||||
test('Set background on a row', function() {
|
||||
altRows.setRowBg(4);
|
||||
deepEqual(tbl.rows[4].className, 'odd', 'Bg set on expected row');
|
||||
|
|
@ -48,6 +85,12 @@ test('Remove background on a row', function() {
|
|||
0, 'Bg set on expected row');
|
||||
});
|
||||
|
||||
test('Remove alternating rows', function() {
|
||||
altRows.destroy();
|
||||
deepEqual(tbl.querySelectorAll('tr.odd').length, 0, 'Odd bgs removed');
|
||||
deepEqual(tbl.querySelectorAll('tr.even').length, 0, 'Even bg removed');
|
||||
});
|
||||
|
||||
test('Grid layout: initialising alternating rows', function() {
|
||||
tf.destroy();
|
||||
tf = null;
|
||||
|
|
@ -82,12 +125,6 @@ test('Grid layout: clear filters', function() {
|
|||
deepEqual(tbl.querySelectorAll('tr.even').length, 4, 'Even bg removed');
|
||||
});
|
||||
|
||||
test('Grid layout: remove alternating rows', function() {
|
||||
altRows.remove();
|
||||
deepEqual(tbl.querySelectorAll('tr.odd').length, 0, 'Odd bgs removed');
|
||||
deepEqual(tbl.querySelectorAll('tr.even').length, 0, 'Even bg removed');
|
||||
});
|
||||
|
||||
test('Grid layout: set background on a row', function() {
|
||||
altRows.setRowBg(4);
|
||||
deepEqual(tbl.rows[4].className, 'odd', 'Bg set on expected row');
|
||||
|
|
@ -98,3 +135,9 @@ test('Grid layout: remove background on a row', function() {
|
|||
deepEqual(tbl.rows[4].querySelectorAll('.odd').length,
|
||||
0, 'Bg set on expected row');
|
||||
});
|
||||
|
||||
test('Grid layout: remove alternating rows', function() {
|
||||
altRows.destroy();
|
||||
deepEqual(tbl.querySelectorAll('tr.odd').length, 0, 'Odd bgs removed');
|
||||
deepEqual(tbl.querySelectorAll('tr.even').length, 0, 'Even bg removed');
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
module('Sanity checks');
|
||||
test('TableFilter object', function() {
|
||||
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
|
||||
deepEqual(tf.id, 'demo', 'id check');
|
||||
deepEqual(tf.getFiltersRowIndex(), 0, 'Filters row index');
|
||||
deepEqual(tf.getHeadersRowIndex(), 1, 'Headers row index');
|
||||
|
|
|
|||
|
|
@ -16,6 +16,48 @@ test('Paging component', function() {
|
|||
deepEqual(paging.pagingLength, 2, 'Paging length');
|
||||
deepEqual(paging.nbPages, 4, 'Number of pages');
|
||||
});
|
||||
module('Feature interface');
|
||||
test('Properties', function() {
|
||||
deepEqual(
|
||||
paging.tf instanceof TableFilter, true, 'TableFilter instance');
|
||||
deepEqual(paging.feature, 'paging', 'Feature name');
|
||||
deepEqual(paging.enabled, true, 'Feature enabled');
|
||||
deepEqual(paging.initialized, true, 'Feature enabled');
|
||||
deepEqual(typeof paging.config, 'object', 'TF configuration object');
|
||||
deepEqual(typeof paging.init, 'function', 'Feature init method');
|
||||
deepEqual(typeof paging.destroy, 'function', 'Feature destroy method');
|
||||
deepEqual(typeof paging.reset, 'function', 'Feature reset method');
|
||||
deepEqual(typeof paging.enable, 'function', 'Feature enable method');
|
||||
deepEqual(typeof paging.disable, 'function', 'Feature enable method');
|
||||
deepEqual(
|
||||
typeof paging.isEnabled, 'function', 'Feature enable method');
|
||||
});
|
||||
test('Can destroy', function() {
|
||||
paging.destroy();
|
||||
deepEqual(paging.enabled, false, 'disabled');
|
||||
});
|
||||
test('Can reset', function() {
|
||||
paging.reset();
|
||||
deepEqual(paging.enabled, true, 'enabled');
|
||||
});
|
||||
test('Can disable', function() {
|
||||
paging.disable();
|
||||
deepEqual(paging.enabled, false, 'disabled');
|
||||
});
|
||||
test('Can enable', function() {
|
||||
paging.enable();
|
||||
deepEqual(paging.enabled, true, 'enabled');
|
||||
});
|
||||
test('Can init', function() {
|
||||
paging.destroy();
|
||||
paging.enable();
|
||||
paging.init();
|
||||
deepEqual(paging.enabled, true, 'enabled');
|
||||
});
|
||||
test('Can check is enabled', function() {
|
||||
paging.isEnabled();
|
||||
deepEqual(paging.enabled, true, 'enabled');
|
||||
});
|
||||
|
||||
module('UI elements');
|
||||
test('Paging UI elements', function() {
|
||||
|
|
|
|||
|
|
@ -4,14 +4,59 @@ var tf = new TableFilter('demo', {
|
|||
rows_counter: true
|
||||
});
|
||||
tf.init();
|
||||
var rowsCounter = tf.feature('rowsCounter');
|
||||
|
||||
module('Sanity checks');
|
||||
test('RowsCounter component', function() {
|
||||
notEqual(tf.feature('rowsCounter'), null, 'RowsCounter instanciated');
|
||||
notEqual(rowsCounter, null, 'RowsCounter instanciated');
|
||||
});
|
||||
|
||||
test('RowsCounter component', function() {
|
||||
equal(tf.feature('rowsCounter').rowsCounterSpan.innerHTML,
|
||||
module('Feature interface');
|
||||
test('Properties', function() {
|
||||
deepEqual(
|
||||
rowsCounter.tf instanceof TableFilter, true, 'TableFilter instance');
|
||||
deepEqual(rowsCounter.feature, 'rowsCounter', 'Feature name');
|
||||
deepEqual(rowsCounter.enabled, true, 'Feature enabled');
|
||||
deepEqual(rowsCounter.initialized, true, 'Feature enabled');
|
||||
deepEqual(typeof rowsCounter.config, 'object', 'TF configuration object');
|
||||
deepEqual(typeof rowsCounter.init, 'function', 'Feature init method');
|
||||
deepEqual(typeof rowsCounter.destroy, 'function', 'Feature destroy method');
|
||||
deepEqual(typeof rowsCounter.reset, 'function', 'Feature reset method');
|
||||
deepEqual(typeof rowsCounter.enable, 'function', 'Feature enable method');
|
||||
deepEqual(typeof rowsCounter.disable, 'function', 'Feature enable method');
|
||||
deepEqual(
|
||||
typeof rowsCounter.isEnabled, 'function', 'Feature enable method');
|
||||
});
|
||||
test('Can destroy', function() {
|
||||
rowsCounter.destroy();
|
||||
deepEqual(rowsCounter.enabled, false, 'disabled');
|
||||
});
|
||||
test('Can reset', function() {
|
||||
rowsCounter.reset();
|
||||
deepEqual(rowsCounter.enabled, true, 'enabled');
|
||||
});
|
||||
test('Can disable', function() {
|
||||
rowsCounter.disable();
|
||||
deepEqual(rowsCounter.enabled, false, 'disabled');
|
||||
});
|
||||
test('Can enable', function() {
|
||||
rowsCounter.enable();
|
||||
deepEqual(rowsCounter.enabled, true, 'enabled');
|
||||
});
|
||||
test('Can init', function() {
|
||||
rowsCounter.destroy();
|
||||
rowsCounter.enable();
|
||||
rowsCounter.init();
|
||||
deepEqual(rowsCounter.enabled, true, 'enabled');
|
||||
});
|
||||
test('Can check is enabled', function() {
|
||||
rowsCounter.isEnabled();
|
||||
deepEqual(rowsCounter.enabled, true, 'enabled');
|
||||
});
|
||||
|
||||
module('Behaviour');
|
||||
test('RowsCounter value', function() {
|
||||
equal(rowsCounter.rowsCounterSpan.innerHTML,
|
||||
7, 'Counter value');
|
||||
});
|
||||
|
||||
|
|
@ -19,13 +64,13 @@ test('RowsCounter component with filtered table', function() {
|
|||
tf.setFilterValue(0, 'Syd');
|
||||
tf.filter();
|
||||
|
||||
equal(tf.feature('rowsCounter').rowsCounterSpan.innerHTML,
|
||||
equal(rowsCounter.rowsCounterSpan.innerHTML,
|
||||
4, 'Counter value');
|
||||
|
||||
tf.clearFilters();
|
||||
});
|
||||
|
||||
module('With pagination');
|
||||
module('Pagination');
|
||||
test('RowsCounter component with paging', function() {
|
||||
tf.destroy();
|
||||
tf = null;
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@
|
|||
});
|
||||
tf.init();
|
||||
|
||||
module("Table 1: sanity checks");
|
||||
test("TableFilter object", function() {
|
||||
equal(tf.id, 'demo', 'id check');
|
||||
equal(tf.filtersRowIndex, 0, 'Filters row index');
|
||||
module('Table 1: sanity checks');
|
||||
test('TableFilter object', function() {
|
||||
deepEqual(tf instanceof TableFilter, true, 'TableFilter instanciated');
|
||||
deepEqual(tf.id, 'demo', 'id check');
|
||||
deepEqual(tf.filtersRowIndex, 0, 'Filters row index');
|
||||
deepEqual(tf.getCellsNb(), 5, 'filters type collection length');
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue