X-Git-Url: https://git.heureux-cyclage.org/w/index.php?a=blobdiff_plain;f=tests%2Fqunit%2Fdata%2Ftestrunner.js;h=b79c1927f3331646631529118d9e3de4c321359c;hb=53779578b44575ef91feb3fad488f09b52f737d7;hp=1091d093f24deef29e979f336cf55e0718d06fe8;hpb=dc96de06464ebd353dd5c45ee9157afce11ddd94;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/qunit/data/testrunner.js b/tests/qunit/data/testrunner.js index 1091d093f2..b79c1927f3 100644 --- a/tests/qunit/data/testrunner.js +++ b/tests/qunit/data/testrunner.js @@ -1,5 +1,4 @@ /*global CompletenessTest, sinon */ -/*jshint evil: true */ ( function ( $, mw, QUnit ) { 'use strict'; @@ -168,10 +167,11 @@ */ QUnit.newMwEnvironment = ( function () { var warn, error, liveConfig, liveMessages, + MwMap = mw.config.constructor, // internal use only ajaxRequests = []; - liveConfig = mw.config.values; - liveMessages = mw.messages.values; + liveConfig = mw.config; + liveMessages = mw.messages; function suppressWarnings() { warn = mw.log.warn; @@ -199,14 +199,14 @@ // NOTE: It is important that we suppress warnings because extend() will also access // deprecated properties and trigger deprecation warnings from mw.log#deprecate. suppressWarnings(); - copy = $.extend( {}, liveConfig, custom ); + copy = $.extend( {}, liveConfig.get(), custom ); restoreWarnings(); return copy; } function freshMessagesCopy( custom ) { - return $.extend( /*deep=*/true, {}, liveMessages, custom ); + return $.extend( /*deep=*/true, {}, liveMessages.get(), custom ); } /** @@ -232,8 +232,15 @@ setup: function () { // Greetings, mock environment! - mw.config.values = freshConfigCopy( localEnv.config ); - mw.messages.values = freshMessagesCopy( localEnv.messages ); + mw.config = new MwMap(); + mw.config.set( freshConfigCopy( localEnv.config ) ); + mw.messages = new MwMap(); + mw.messages.set( freshMessagesCopy( localEnv.messages ) ); + // Update reference to mw.messages + mw.jqueryMsg.setParserDefaults( { + messages: mw.messages + } ); + this.suppressWarnings = suppressWarnings; this.restoreWarnings = restoreWarnings; @@ -252,8 +259,12 @@ $( document ).off( 'ajaxSend', trackAjax ); // Farewell, mock environment! - mw.config.values = liveConfig; - mw.messages.values = liveMessages; + mw.config = liveConfig; + mw.messages = liveMessages; + // Restore reference to mw.messages + mw.jqueryMsg.setParserDefaults( { + messages: liveMessages + } ); // As a convenience feature, automatically restore warnings if they're // still suppressed by the end of the test.