Merge "wfProfileOut() for new return added in c6396 (c4e407c)"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / jquery / jquery.tablesorter.test.js
index e90b9a6..f028dbc 100644 (file)
@@ -1,12 +1,13 @@
-(function() {
+( function ( $ ) {
 
-module( 'jquery.tablesorter' );
-
-// setup hack
-mw.config.set( 'wgMonthNames', [ '', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ] );
-mw.config.set( 'wgMonthNamesShort', ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] );
-mw.config.set( 'wgDefaultDateFormat', 'dmy' );
+var config = {
+       wgMonthNames: ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
+       wgMonthNamesShort: ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
+       wgDefaultDateFormat: 'dmy',
+       wgContentLanguage: 'en'
+};
 
+module( 'jquery.tablesorter', QUnit.newMwEnvironment({ config: config }) );
 
 test( '-- Initial check', function() {
        expect(1);
@@ -78,7 +79,6 @@ var tableTest = function( msg, header, data, expected, callback ) {
                expect(1);
 
                var $table = tableCreate( header, data );
-               //$( 'body' ).append($table);
 
                // Give caller a chance to set up sorting and manipulate the table.
                callback( $table );
@@ -181,8 +181,9 @@ tableTest(
                ['11.11.2011']
        ],
        function( $table ) {
-               // @fixme reset it at end or change module to allow us to override it
                mw.config.set( 'wgDefaultDateFormat', 'dmy' );
+               mw.config.set( 'wgContentLanguage', 'de' );
+
                $table.tablesorter();
                $table.find( '.headerSort:eq(0)' ).click();
        }
@@ -206,8 +207,8 @@ tableTest(
                ['11.11.2011']
        ],
        function( $table ) {
-               // @fixme reset it at end or change module to allow us to override it
                mw.config.set( 'wgDefaultDateFormat', 'mdy' );
+
                $table.tablesorter();
                $table.find( '.headerSort:eq(0)' ).click();
        }
@@ -293,9 +294,9 @@ tableTest(
                        'ß': 'ss',
                        'ü':'ue'
                } );
+
                $table.tablesorter();
                $table.find( '.headerSort:eq(0)' ).click();
-               mw.config.set( 'tableSorterCollation', {} );
        }
 );
 
@@ -361,6 +362,7 @@ tableTest(
        complexMDYSorted,
        function( $table ) {
                mw.config.set( 'wgDefaultDateFormat', 'mdy' );
+
                $table.tablesorter();
                $table.find( '.headerSort:eq(0)' ).click();
        }
@@ -492,7 +494,7 @@ var numbers = [
        [ '13,000'],
        [  '9'    ],
        [ '14'    ],
-       [  '8.0'  ],
+       [  '8.0'  ]
 ];
 var numbersAsc = [
        [  '7'    ],
@@ -500,7 +502,7 @@ var numbersAsc = [
        [  '9'    ],
        [ '12'    ],
        [ '14'    ],
-       [ '13,000'],
+       [ '13,000']
 ];
 
 tableTest( 'bug 8115: sort numbers with commas (ascending)',
@@ -511,8 +513,6 @@ tableTest( 'bug 8115: sort numbers with commas (ascending)',
        }
 );
 
-alert( mw.config.get( "wgContentLanguage" ) );
-
 tableTest( 'bug 8115: sort numbers with commas (descending)',
        ['Numbers'], numbers, reversed(numbersAsc),
        function( $table ) {
@@ -522,5 +522,31 @@ tableTest( 'bug 8115: sort numbers with commas (descending)',
 );
 // TODO add numbers sorting tests for bug 8115 with a different language
 
+test( 'bug 32888 - Tables inside a tableheader cell', function() {
+       expect(2);
+
+       var $table;
+       $table = $(
+               '<table class="sortable" id="32888">' +
+               '<tr><th>header<table id="32888-2">'+
+                       '<tr><th>1</th><th>2</th></tr>' +
+               '</table></th></tr>' +
+               '<tr><td>A</td></tr>' +
+               '<tr><td>B</td></tr>' +
+               '</table>'
+               );
+       $table.tablesorter();
+
+       equals(
+               $table.find('> thead:eq(0) > tr > th.headerSort').length,
+               1,
+               'Child tables inside a headercell should not interfere with sortable headers (bug 32888)'
+       );
+       equals(
+               $('#32888-2').find('th.headerSort').length,
+               0,
+               'The headers of child tables inside a headercell should not be sortable themselves (bug 32888)'
+       );
+});
 
-})();
+})( jQuery );