QUnit: fix swapped expected/actual fields
[lhc/web/wiklou.git] / tests / qunit / suites / resources / jquery / jquery.tablesorter.test.js
index fe174ce..2fd3ce9 100644 (file)
@@ -1,5 +1,5 @@
 ( function ( $, mw ) {
-       var config, header,
+       var header,
 
                // Data set "simple"
                a1 = [ 'A', '1' ],
                        ['February 05 2010']
                ];
 
-       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',
-               wgSeparatorTransformTable: ['', ''],
-               wgDigitTransformTable: ['', ''],
-               wgContentLanguage: 'en'
-       };
-
-       QUnit.module( 'jquery.tablesorter', QUnit.newMwEnvironment( { config: config } ) );
+       QUnit.module( 'jquery.tablesorter', QUnit.newMwEnvironment( {
+               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',
+                       wgSeparatorTransformTable: ['', ''],
+                       wgDigitTransformTable: ['', ''],
+                       wgContentLanguage: 'en'
+               }
+       } ) );
 
        /**
         * Create an HTML table from an array of row arrays containing text strings.
                );
        } );
 
+       QUnit.test( 'holes in the table headers should not throw JS errors', 2, function ( assert ) {
+               var $table = $(
+                       '<table class="sortable">' +
+                               '<thead>' +
+                               '<tr><th id="A1">A1</th><th>B1</th><th id="C1" rowspan="2">C1</th></tr>' +
+                               '<tr><th id="A2">A2</th></tr>' +
+                               '</thead>' +
+                               '<tr><td>A</td><td>Aa</td><td>Aaa</td></tr>' +
+                               '<tr><td>B</td><td>Ba</td><td>Bbb</td></tr>' +
+                               '</table>'
+               );
+               $table.tablesorter();
+               assert.equal( $table.find( '#A2' ).prop( 'headerIndex' ),
+                       0,
+                       'A2 should not be a sort header'
+               );
+               assert.equal( $table.find( '#C1' ).prop( 'headerIndex' ),
+                       1,
+                       'C1 should be a sort header, but will sort the wrong column'
+               );
+       } );
+
        // bug 41889 - exploding rowspans in more complex cases
        tableTestHTML(
                'Rowspan exploding with row headers',
                ]
        );
 
+       // bug 53211 - exploding rowspans in more complex cases
+       QUnit.test(
+               'Rowspan exploding with row headers and colspans', 1, function ( assert ) {
+               var $table = $( '<table class="sortable">' +
+                       '<thead><tr><th rowspan="2">n</th><th colspan="2">foo</th><th rowspan="2">baz</th></tr>' +
+                       '<tr><th>foo</th><th>bar</th></tr></thead>' +
+                       '<tbody>' +
+                       '<tr><td>1</td><td>foo</td><td>bar</td><td>baz</td></tr>' +
+                       '<tr><td>2</td><td>foo</td><td>bar</td><td>baz</td></tr>' +
+                       '</tbody></table>' );
+
+                       $table.tablesorter();
+                       assert.equal( $table.find( 'tr:eq(1) th:eq(1)').prop('headerIndex'),
+                               2,
+                               'Incorrect index of sort header' );
+               }
+       );
+
        tableTestHTML(
                'Rowspan exploding with colspanned cells',
                '<table class="sortable">' +