Merge "mw.Upload.BookletLayout: Improve error message when not all logged-in users...
[lhc/web/wiklou.git] / tests / qunit / suites / resources / jquery / jquery.tablesorter.test.js
index 8026cc3..ca26aaf 100644 (file)
                        [ 'Strasse' ]
                ],
 
+               // Data set "digraph"
+               digraphWords = [
+                       [ 'London' ],
+                       [ 'Ljubljana' ],
+                       [ 'Luxembourg' ],
+                       [ 'Njivice' ],
+                       [ 'Norwich' ],
+                       [ 'New York' ]
+               ],
+               digraphWordsSorted = [
+                       [ 'London' ],
+                       [ 'Luxembourg' ],
+                       [ 'Ljubljana' ],
+                       [ 'New York' ],
+                       [ 'Norwich' ],
+                       [ 'Njivice' ]
+               ],
+
                complexMDYDates = [
                        [ 'January, 19 2010' ],
                        [ 'April 21 1991' ],
         * Create an HTML table from an array of row arrays containing text strings.
         * First row will be header row. No fancy rowspan/colspan stuff.
         *
-        * @param {String[]} header
-        * @param {String[][]} data
+        * @param {string[]} header
+        * @param {string[][]} data
         * @return {jQuery}
         */
        function tableCreate( header, data ) {
         * Extract text from table.
         *
         * @param {jQuery} $table
-        * @return {String[][]}
+        * @return {string[][]}
         */
        function tableExtract( $table ) {
                var data = [];
         * Run a table test by building a table with the given data,
         * running some callback on it, then checking the results.
         *
-        * @param {String} msg text to pass on to qunit for the comparison
-        * @param {String[]} header cols to make the table
-        * @param {String[][]} data rows/cols to make the table
-        * @param {String[][]} expected rows/cols to compare against at end
+        * @param {string} msg text to pass on to qunit for the comparison
+        * @param {string[]} header cols to make the table
+        * @param {string[][]} data rows/cols to make the table
+        * @param {string[][]} expected rows/cols to compare against at end
         * @param {function($table)} callback something to do with the table before we compare
         */
        function tableTest( msg, header, data, expected, callback ) {
         * Run a table test by building a table with the given HTML,
         * running some callback on it, then checking the results.
         *
-        * @param {String} msg text to pass on to qunit for the comparison
-        * @param {String} HTML to make the table
-        * @param {String[][]} expected rows/cols to compare against at end
-        * @param {function($table)} callback something to do with the table before we compare
+        * @param {string} msg text to pass on to qunit for the comparison
+        * @param {string} html HTML to make the table
+        * @param {string[][]} expected Rows/cols to compare against at end
+        * @param {function($table)} callback Something to do with the table before we compare
         */
        function tableTestHTML( msg, html, expected, callback ) {
                QUnit.test( msg, 1, function ( assert ) {
                }
        );
 
+       tableTest(
+               'Digraphs with custom collation',
+               [ 'City' ],
+               digraphWords,
+               digraphWordsSorted,
+               function ( $table ) {
+                       mw.config.set( 'tableSorterCollation', {
+                               lj: 'lzzzz',
+                               nj: 'nzzzz'
+                       } );
+
+                       $table.tablesorter();
+                       $table.find( '.headerSort:eq(0)' ).click();
+               }
+       );
+
        QUnit.test( 'Rowspan not exploded on init', 1, function ( assert ) {
                var $table = tableCreate( header, planets );
 
                        0,
                        'empty cell is sorted as number 0'
                );
+       } );
 
+       QUnit.test( 'bug T114721 - use of expand-child class', 2, function ( assert ) {
+               var $table, parsers;
+               $table = $(
+                       '<table class="sortable">' +
+                               '<tr><th>A</th><th>B</th></tr>' +
+                               '<tr><td>b</td><td>4</td></tr>' +
+                               '<tr class="expand-child"><td colspan="2">some text follow b</td></tr>' +
+                               '<tr><td>a</td><td>2</td></tr>' +
+                               '<tr class="expand-child"><td colspan="2">some text follow a</td></tr>' +
+                               '<tr class="expand-child"><td colspan="2">more text</td></tr>' +
+                               '</table>'
+               );
+               $table.tablesorter();
+               $table.find( '.headerSort:eq(0)' ).click();
+
+               assert.deepEqual(
+                       tableExtract( $table ),
+                       [
+                               [ 'a', '2' ],
+                               [ 'some text follow a' ],
+                               [ 'more text' ],
+                               [ 'b', '4' ],
+                               [ 'some text follow b' ]
+                       ],
+                       'row with expand-child class follow above row'
+               );
+
+               parsers = $table.data( 'tablesorter' ).config.parsers;
+               assert.equal(
+                       parsers[ 1 ].id,
+                       'number',
+                       'detectParserForColumn() detect parser.id "number" for second column'
+               );
        } );
+
 }( jQuery, mediaWiki ) );