From: jenkins-bot Date: Wed, 19 Sep 2018 19:08:40 +0000 (+0000) Subject: Merge "mw.jqueryMsg: Add tests for non-string parameters to functions that expect... X-Git-Tag: 1.34.0-rc.0~4054 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=216c7d838012c52961c955f40a93af8a4087e68f;hp=95ec6c6029fae3af265b39d33bdc828eb706939e;p=lhc%2Fweb%2Fwiklou.git Merge "mw.jqueryMsg: Add tests for non-string parameters to functions that expect strings" --- diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js b/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js index 2491ca3b70..7e6ceb782e 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js @@ -1154,6 +1154,69 @@ assert.strictEqual( logSpy.callCount, 2, 'mw.log.warn calls' ); } ); + QUnit.test( 'Non-string parameters to various functions', function ( assert ) { + var i, cases; + + // For jquery-param-grammar + mw.language.setData( 'en', 'grammarTransformations', { + test: [ + [ 'x', 'y' ] + ] + } ); + + cases = [ + { + key: 'jquery-param-wikilink', + msg: '[[$1]] [[$1|a]]', + expected: 'x a' + }, + { + key: 'jquery-param-plural', + msg: '{{PLURAL:$1|a|b}}', + expected: 'b' + }, + { + key: 'jquery-param-gender', + msg: '{{GENDER:$1|a|b}}', + expected: 'a' + }, + { + key: 'jquery-param-grammar', + msg: '{{GRAMMAR:test|$1}}', + expected: '{{GRAMMAR:test|$1}}' + }, + { + key: 'jquery-param-int', + msg: '{{int:$1}}', + expected: '{{int:$1}}' + }, + { + key: 'jquery-param-ns', + msg: '{{ns:$1}}', + expected: '' + }, + { + key: 'jquery-param-formatnum', + msg: '{{formatnum:$1}}', + expected: '[object Object]' + }, + { + key: 'jquery-param-case', + msg: '{{lc:$1}} {{uc:$1}} {{lcfirst:$1}} {{ucfirst:$1}}', + expected: 'x X x X' + } + ]; + + for ( i = 0; i < cases.length; i++ ) { + mw.messages.set( cases[ i ].key, cases[ i ].msg ); + assert.strictEqual( + mw.message( cases[ i ].key, $( '' ).text( 'x' ) ).parse(), + cases[ i ].expected, + cases[ i ].key + ); + } + } ); + QUnit.test( 'Integration', function ( assert ) { var expected, msg;