Merge "MWException: Don't send headers multiple times"
[lhc/web/wiklou.git] / tests / qunit / suites / resources / mediawiki / mediawiki.util.test.js
index 9707ab9..b2587be 100644 (file)
@@ -1,11 +1,15 @@
 ( function ( mw, $ ) {
        QUnit.module( 'mediawiki.util', QUnit.newMwEnvironment( {
                setup: function () {
-                       this.taPrefix = mw.util.tooltipAccessKeyPrefix;
-                       mw.util.tooltipAccessKeyPrefix = 'ctrl-alt-';
+                       $.fn.updateTooltipAccessKeys.setTestMode( true );
                },
                teardown: function () {
-                       mw.util.tooltipAccessKeyPrefix = this.taPrefix;
+                       $.fn.updateTooltipAccessKeys.setTestMode( false );
+               },
+               messages: {
+                       // Used by accessKeyLabel in test for addPortletLink
+                       'brackets': '[$1]',
+                       'word-separator': ' '
                }
        } ) );
 
@@ -89,6 +93,8 @@
        } );
 
        QUnit.test( 'tooltipAccessKey', 4, function ( assert ) {
+               this.suppressWarnings();
+
                assert.equal( typeof mw.util.tooltipAccessKeyPrefix, 'string', 'tooltipAccessKeyPrefix must be a string' );
                assert.equal( $.type( mw.util.tooltipAccessKeyRegexp ), 'regexp', 'tooltipAccessKeyRegexp is a regexp' );
                assert.ok( mw.util.updateTooltipAccessKeys, 'updateTooltipAccessKeys is non-empty' );
                'Example [a]'.replace( mw.util.tooltipAccessKeyRegexp, function ( sub, m1, m2, m3, m4, m5, m6 ) {
                        assert.equal( m6, 'a', 'tooltipAccessKeyRegexp finds the accesskey hint' );
                } );
+
+               this.restoreWarnings();
        } );
 
        QUnit.test( '$content', 2, function ( assert ) {
                assert.ok( $.isDomElement( tbRL ), 'addPortletLink returns a valid DOM Element according to $.isDomElement' );
 
                tbMW = mw.util.addPortletLink( 'p-test-tb', '//mediawiki.org/',
-                       'MediaWiki.org', 't-mworg', 'Go to MediaWiki.org ', 'm', tbRL );
+                       'MediaWiki.org', 't-mworg', 'Go to MediaWiki.org', 'm', tbRL );
                $tbMW = $( tbMW );
 
                assert.propEqual(
                        $tbMW.find( 'a' ).getAttrs(),
                        {
                                href: '//mediawiki.org/',
-                               title: 'Go to MediaWiki.org [ctrl-alt-m]',
+                               title: 'Go to MediaWiki.org [test-m]',
                                accesskey: 'm'
                        },
                        'Validate attributes of anchor tag in created element'
                cuQuux = mw.util.addPortletLink( 'p-test-custom', '#', 'Quux', null, 'Example [shift-x]', 'q' );
                $cuQuux = $( cuQuux );
 
-               assert.equal( $cuQuux.find( 'a' ).attr( 'title' ), 'Example [ctrl-alt-q]', 'Existing accesskey is stripped and updated' );
+               assert.equal( $cuQuux.find( 'a' ).attr( 'title' ), 'Example [test-q]', 'Existing accesskey is stripped and updated' );
 
                assert.equal(
                        $( '#p-test-custom #c-barmenu ul li' ).length,
        } );
 
        QUnit.test( 'jsMessage', 1, function ( assert ) {
+               this.suppressWarnings();
                var a = mw.util.jsMessage( 'MediaWiki is <b>Awesome</b>.' );
+               this.restoreWarnings();
                assert.ok( a, 'Basic checking of return value' );
 
                // Clean up