1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-19 06:47:00 +02:00
TableFilter/test/test-paging.js

40 lines
1.7 KiB
JavaScript
Raw Normal View History

2015-05-14 12:08:19 +02:00
var id = function (id){ return document.getElementById(id); };
2015-05-14 12:08:19 +02:00
var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
paging: true,
paging_length: 2,
results_per_page: ['Results per page', [2,4,6]]
});
tf.init();
var paging = tf.feature('paging');
2015-05-14 12:08:19 +02:00
module('Sanity checks');
test('Paging component', function() {
notEqual(paging, null, 'Paging instanciated');
deepEqual(paging.pagingLength, 2, 'Paging length');
deepEqual(paging.nbPages, 4, 'Number of pages');
});
2015-05-14 12:08:19 +02:00
module('UI elements');
test('Paging UI elements', function() {
notEqual(paging.pagingSlc, null, 'Paging drop-down element');
notEqual(paging.resultsPerPageSlc, null, 'Number of results per page drop-down element');
notEqual(id(paging.prfxBtnNextSpan+tf.id), null, 'Next button container element');
notEqual(id(paging.prfxBtnPrevSpan+tf.id), null, 'Previous button container element');
notEqual(id(paging.prfxBtnLastSpan+tf.id), null, 'Last button container element');
notEqual(id(paging.prfxBtnFirstSpan+tf.id), null, 'First button container element');
});
2015-05-14 12:08:19 +02:00
test('Destroy Paging component', function() {
paging.destroy();
deepEqual(paging.pagingSlc, null, 'Paging drop-down element');
deepEqual(paging.resultsPerPageSlc, null, 'Paging drop-down element');
deepEqual(id(paging.prfxBtnNextSpan+tf.id), null, 'Next button container element');
deepEqual(id(paging.prfxBtnPrevSpan+tf.id), null, 'Previous button container element');
deepEqual(id(paging.prfxBtnLastSpan+tf.id), null, 'Last button container element');
deepEqual(id(paging.prfxBtnFirstSpan+tf.id), null, 'First button container element');
deepEqual(paging.nbPages, 0, 'Number of pages');
});