r90655 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90654‎ | r90655 | r90656 >
Date:07:39, 23 June 2011
Author:diebuche
Status:ok (Comments)
Tags:
Comment:
Adding a collation test to tablesorter, fixing var ref from r90630
Modified paths:
  • /trunk/phase3/resources/jquery/jquery.tablesorter.js (modified) (history)
  • /trunk/phase3/tests/qunit/index.html (modified) (history)
  • /trunk/phase3/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/index.html
@@ -60,7 +60,7 @@
6161 <script src="suites/resources/jquery/jquery.autoEllipsis.js"></script>
6262 <script src="suites/resources/jquery/jquery.colorUtil.js"></script>
6363 <script src="suites/resources/jquery/jquery.tabIndex.js"></script>
64 - <script src="suites/resources/jquery/jquery.tablesorter.test.js"></script>
 64+ <script src="suites/resources/jquery/jquery.tablesorter.test.js" charset="UTF-8"></script>
6565 <script src="suites/resources/mediawiki/mediawiki.Title.js"></script>
6666
6767 <!-- TestSwarm: If a test swarm is running this,
Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
@@ -27,7 +27,7 @@
2828 $.each(header, function(i, str) {
2929 var $th = $('<th>');
3030 $th.text(str).appendTo($tr);
31 - })
 31+ });
3232 $tr.appendTo($thead);
3333
3434 for (var i = 0; i < data.length; i++) {
@@ -35,7 +35,7 @@
3636 $.each(data[i], function(j, str) {
3737 var $td = $('<td>');
3838 $td.text(str).appendTo($tr);
39 - })
 39+ });
4040 $tr.appendTo($tbody);
4141 }
4242 return $table;
@@ -53,7 +53,7 @@
5454 var row = [];
5555 $(tr).find('td,th').each(function(i, td) {
5656 row.push($(td).text());
57 - })
 57+ });
5858 data.push(row);
5959 });
6060 return data;
@@ -82,7 +82,7 @@
8383 // Table sorting is done synchronously; if it ever needs to change back
8484 // to asynchronous, we'll need a timeout or a callback here.
8585 var extracted = tableExtract( $table );
86 - deepEqual( extracted, expected, msg )
 86+ deepEqual( extracted, expected, msg );
8787 });
8888 };
8989
@@ -90,7 +90,7 @@
9191 var arr2 = arr.slice(0);
9292 arr2.reverse();
9393 return arr2;
94 -}
 94+};
9595
9696 // Sample data set: some planets!
9797 var header = ['Planet', 'Radius (km)'],
@@ -255,4 +255,47 @@
256256 }
257257 );
258258
 259+var umlautWords = [
 260+ // Some words with Umlauts
 261+ ['Günther'],
 262+ ['Peter'],
 263+ ['Björn'],
 264+ ['Bjorn'],
 265+ ['Apfel'],
 266+ ['Äpfel'],
 267+ ['Strasse'],
 268+ ['Sträßschen']
 269+];
 270+
 271+var umlautWordsSorted = [
 272+ // Some words with Umlauts
 273+ ['Äpfel'],
 274+ ['Apfel'],
 275+ ['Björn'],
 276+ ['Bjorn'],
 277+ ['Günther'],
 278+ ['Peter'],
 279+ ['Sträßschen'],
 280+ ['Strasse']
 281+];
 282+
 283+tableTest(
 284+ 'Accented Characters with custom collation',
 285+ ['Name'],
 286+ umlautWords,
 287+ umlautWordsSorted,
 288+ function( $table ) {
 289+ mw.config.set('tableSorterCollation', {'ä':'ae', 'ö' : 'oe', 'ß': 'ss', 'ü':'ue'});
 290+ $table.tablesorter();
 291+ $table.find('.headerSort:eq(0)').click();
 292+ mw.config.set('tableSorterCollation', {});
 293+ }
 294+);
 295+
 296+
 297+
 298+
 299+
 300+
 301+
259302 })();
Index: trunk/phase3/resources/jquery/jquery.tablesorter.js
@@ -481,7 +481,7 @@
482482 }
483483 }
484484 if (keys.length) {
485 - ts.collationRegex = new RegExp( '[' + ts.collationRegex.join('') + ']', 'ig' );
 485+ ts.collationRegex = new RegExp( '[' + keys.join('') + ']', 'ig' );
486486 }
487487 }
488488 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r90667Set window.wgMonthNamesShort before we start the tests, to be able to pass ad...hartman17:20, 23 June 2011
r91782MFT to REL_1_18: jquery tablesorter...hashar08:54, 9 July 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r90630Followup r86088, r87244, r90612: fix jquery.tablesorter for null collation ta...brion23:19, 22 June 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   20:13, 23 June 2011

Looks good; note that in addition to the test this includes a fix, and needs merging to 1.18.

Status & tagging log