'use strict';
var util,
- config = require( './config.json' ),
- origConfig = config;
+ config = require( './config.json' );
/**
* Encode the string like PHP's rawurlencode
*/
util = {
- /* Main body */
-
- setOptionsForTest: function ( opts ) {
- if ( !window.QUnit ) {
- throw new Error( 'Modifying options not allowed outside unit tests' );
- }
- config = $.extend( {}, config, opts );
- },
-
- resetOptionsForTest: function () {
- if ( !window.QUnit ) {
- throw new Error( 'Resetting options not allowed outside unit tests' );
- }
- config = origConfig;
- },
-
/**
* Encode the string like PHP's rawurlencode
*
}
};
+ // Not allowed outside unit tests
+ if ( window.QUnit ) {
+ util.setOptionsForTest = function ( opts ) {
+ var oldConfig = config;
+ config = $.extend( {}, config, opts );
+ return oldConfig;
+ };
+ }
+
/**
* Initialisation of mw.util.$content
*/
QUnit.module( 'mediawiki.util', QUnit.newMwEnvironment( {
setup: function () {
$.fn.updateTooltipAccessKeys.setTestMode( true );
+ this.origConfig = mw.util.setOptionsForTest( {
+ FragmentMode: [ 'legacy', 'html5' ],
+ LoadScript: '/w/load.php'
+ } );
},
teardown: function () {
$.fn.updateTooltipAccessKeys.setTestMode( false );
- mw.util.resetOptionsForTest();
+ mw.util.setOptionsForTest( this.origConfig );
},
messages: {
// Used by accessKeyLabel in test for addPortletLink