1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-03 15:13:15 +02:00
TableFilter/test/test-integration-paging-sort.js

52 lines
1.5 KiB
JavaScript

var id = function (id){ return document.getElementById(id); };
var tf = new TableFilter('demo', {
base_path: '../dist/tablefilter/',
paging: true,
paging_length: 2,
remember_grid_values: true,
remember_page_number: true,
remember_page_length: true,
results_per_page: ['Results per page ', [2,4,6]],
extensions: [{ name: 'sort' }]
});
tf.init();
var paging = tf.feature('paging');
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');
});
test('Sort extension', function() {
var sort = tf.extension('sort');
notEqual(sort, null, 'Sort instanciated');
deepEqual(sort.stt instanceof SortableTable, true, 'Sort type');
deepEqual(sort.sorted, false, 'Table not sorted');
deepEqual(sort.initialized, true, 'Sort initialized');
});
module('Paging with persistence when a column is sorted');
test('It contains options', function() {
var sort = tf.extension('sort');
sort.sortByColumnIndex(0);
deepEqual(paging.pagingSlc.options.length, 4, 'Expected options number');
});
test('Can select a page', function() {
var sort = tf.extension('sort');
sort.sortByColumnIndex(1);
paging.setPage(3);
deepEqual(paging.pagingSlc.selectedIndex, 2, 'Expected options number');
});
module('Tear-down');
test('can destroy TableFilter DOM elements', function() {
tf.destroy();
deepEqual(tf.hasGrid(), false, 'Filters removed');
});