X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;ds=sidebyside;f=resources%2Fsrc%2Fmediawiki.util.js;h=7cda45fb2883228d659365a79b9f85e2761da04e;hb=d3a4ac1bb6accbaf3be0c0067358b64184a03490;hp=65fe3d3e8fa44bd8caf9e456edbfbe549372ddec;hpb=0833cae960f3360c1e2208122ed17dae08e24a90;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.util.js b/resources/src/mediawiki.util.js index 65fe3d3e8f..7cda45fb28 100644 --- a/resources/src/mediawiki.util.js +++ b/resources/src/mediawiki.util.js @@ -1,7 +1,9 @@ ( function () { 'use strict'; - var util; + var util, + config = require( './config.json' ), + origConfig = config; /** * Encode the string like PHP's rawurlencode @@ -50,6 +52,20 @@ /* 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 * @@ -68,7 +84,7 @@ * @return {string} Encoded string */ escapeIdForAttribute: function ( str ) { - var mode = mw.config.get( 'wgFragmentMode' )[ 0 ]; + var mode = config.FragmentMode[ 0 ]; return escapeIdInternal( str, mode ); }, @@ -83,7 +99,7 @@ * @return {string} Encoded string */ escapeIdForLink: function ( str ) { - var mode = mw.config.get( 'wgFragmentMode' )[ 0 ]; + var mode = config.FragmentMode[ 0 ]; return escapeIdInternal( str, mode ); },