/*! * TableSorter QUnit Testing */ /*jshint unused: false */ /*global QUnit: false, JSHINT: false, ok: false, start: false, deepEqual: false, asyncTest: false */ /* Core plugin tested ======================== OPTIONS: cssAsc, cssChildRow, cssDesc, cssHeader, cssHeaderRow, cssInfoBlock, dateFormat, emptyTo, headerList, headers, ignoreCase, initialized, parsers, sortList, sortLocaleCompare, sortReset, stringTo, tableClass, usNumberFormat, widgets (just zebra), sortAppend, sortForce, sortMultiSortKey, sortResetKey, numberSorter METHODS: addRows, applyWidgets, destroy, sorton, sortReset, update/updateRow, updateAll, updateCell EVENTS: initialized, sortBegin, sortEnd, sortStart, updateComplete Not yet tested ========================= OPTIONS: cancelSelection, cssIcon, cssProcessing, debug, delayInit, headerTemplate, initWidgets, onRenderHeader, onRenderTemplate, selectorHeaders, selectorRemove, selectorSort, serverSideSorting, showProcessing, sortInitialOrder, sortRestart, strings, textExtraction, textSorter, theme, widthFixed, widgets (also need priority testing) METHODS: appendCache, applyWidgetId, sort, refreshWidgets EVENTS: - */ $(function(){ var ts = $.tablesorter, // filter widget table $table = $('#testblock').html('' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '' + '
RankFirst NameLast NameAgeTotalDiscountDate
1Philip Aaron WongJohnson Sr Esq25$5.9522%Jun 26, 2004 7:22 AM
11AaronHibert12$2.995%Aug 21, 2009 12:21 PM
12Brandon ClarkHenry Jr51$42.2918%Oct 13, 2000 1:15 PM
111PeterParker28$9.9920%Jul 6, 2006 8:14 AM
21JohnHood33$19.9925%Dec 10, 2002 5:14 AM
013ClarkKent Sr.18$15.8944%Jan 12, 2003 11:14 AM
005BruceAlmighty Esq45$153.1944%Jan 18, 2021 9:12 AM
10AlexDumass13$5.294%Jan 8, 2012 5:11 PM
16JimFranco24$14.1914%Jan 14, 2004 11:23 AM
166Bruce LeeEvans22$13.1911%Jan 18, 2007 9:12 AM
100Brenda DexterMcMasters18$55.2015%Feb 12, 2010 7:23 PM
55DennisBronson65$123.0032%Jan 20, 2001 1:12 PM
9MarthadelFuego25$22.0917%Jun 11, 2011 10:55 AM
').find('table'), table = $table[0], /************************************************ Filter widget ************************************************/ init = false, runOnce = false, runFilterTests = function(){ var c = table.config, wo = c.widgetOptions; test( "Filter widget", function() { expect(5); equal( init, true, "Init event" ); equal( $table.hasClass('hasFilters'), true, '"hasFilters" class applied' ); equal( ts.filter.regex.child.test( c.cssChildRow ), true, "child row regex check" ); equal( ts.filter.regex.filtered.test( wo.filter_filteredRow ), true, "filtered row regex check" ); tester.cacheCompare( table, 3, [ 12, 18, 13, 18 ], "starting filter value on age column", true ); }); }; $table .on('filterInit', function(){ init = true; }) .on('filterEnd', function(){ if (!runOnce) { runOnce = true; console.log('ok', $table.find('tr')); runFilterTests(); } }) .tablesorter({ widgets: ["zebra", "filter"], initialized: function(){ } }); });