jenkins-bot has submitted this change and it was merged.

Change subject: qunit: Make use of 'config' and 'messages' shortcuts in module 
setup
......................................................................


qunit: Make use of 'config' and 'messages' shortcuts in module setup

While calling mw.config and mw.messages manually works fine (the sandbox
covers mw.config and mw.messages in general, not just when using the
shortcut), let's consistently use the shortcuts.

Also clean up the extra local variable in some cases.

Change-Id: I9ac467ad87816c7dc681b62e9b085b643024c15e
---
M tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
M tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
M tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js
M tests/qunit/suites/resources/mediawiki/mediawiki.test.js
4 files changed, 111 insertions(+), 114 deletions(-)

Approvals:
  Mattflaschen: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js 
b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
index d9801d9..9216ac9 100644
--- a/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
+++ b/tests/qunit/suites/resources/jquery/jquery.tablesorter.test.js
@@ -1,5 +1,5 @@
 ( function ( $, mw ) {
-       var config, header,
+       var header,
 
                // Data set "simple"
                a1 = [ 'A', '1' ],
@@ -155,16 +155,16 @@
                        ['February 05 2010']
                ];
 
-       config = {
-               wgMonthNames: ['', 'January', 'February', 'March', 'April', 
'May', 'June', 'July', 'August', 'September', 'October', 'November', 
'December'],
-               wgMonthNamesShort: ['', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 
'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
-               wgDefaultDateFormat: 'dmy',
-               wgSeparatorTransformTable: ['', ''],
-               wgDigitTransformTable: ['', ''],
-               wgContentLanguage: 'en'
-       };
-
-       QUnit.module( 'jquery.tablesorter', QUnit.newMwEnvironment( { config: 
config } ) );
+       QUnit.module( 'jquery.tablesorter', QUnit.newMwEnvironment( {
+               config: {
+                       wgMonthNames: ['', 'January', 'February', 'March', 
'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 
'December'],
+                       wgMonthNamesShort: ['', 'Jan', 'Feb', 'Mar', 'Apr', 
'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
+                       wgDefaultDateFormat: 'dmy',
+                       wgSeparatorTransformTable: ['', ''],
+                       wgDigitTransformTable: ['', ''],
+                       wgContentLanguage: 'en'
+               }
+       } ) );
 
        /**
         * Create an HTML table from an array of row arrays containing text 
strings.
diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js 
b/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
index 61d662b..077ce70 100644
--- a/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
+++ b/tests/qunit/suites/resources/mediawiki/mediawiki.Title.test.js
@@ -1,60 +1,6 @@
 /*jshint -W024 */
 ( function ( mw, $ ) {
-       // mw.Title relies on these three config vars
-       // Restore them after each test run
-       var config = {
-               wgFormattedNamespaces: {
-                       '-2': 'Media',
-                       '-1': 'Special',
-                       0: '',
-                       1: 'Talk',
-                       2: 'User',
-                       3: 'User talk',
-                       4: 'Wikipedia',
-                       5: 'Wikipedia talk',
-                       6: 'File',
-                       7: 'File talk',
-                       8: 'MediaWiki',
-                       9: 'MediaWiki talk',
-                       10: 'Template',
-                       11: 'Template talk',
-                       12: 'Help',
-                       13: 'Help talk',
-                       14: 'Category',
-                       15: 'Category talk',
-                       // testing custom / localized namespace
-                       100: 'Penguins'
-               },
-               wgNamespaceIds: {
-                       'media': -2,
-                       'special': -1,
-                       '': 0,
-                       'talk': 1,
-                       'user': 2,
-                       'user_talk': 3,
-                       'wikipedia': 4,
-                       'wikipedia_talk': 5,
-                       'file': 6,
-                       'file_talk': 7,
-                       'mediawiki': 8,
-                       'mediawiki_talk': 9,
-                       'template': 10,
-                       'template_talk': 11,
-                       'help': 12,
-                       'help_talk': 13,
-                       'category': 14,
-                       'category_talk': 15,
-                       'image': 6,
-                       'image_talk': 7,
-                       'project': 4,
-                       'project_talk': 5,
-                       // Testing custom namespaces and aliases
-                       'penguins': 100,
-                       'antarctic_waterfowl': 100
-               },
-               wgCaseSensitiveNamespaces: []
-       },
-       repeat = function ( input, multiplier ) {
+       var repeat = function ( input, multiplier ) {
                return new Array( multiplier + 1 ).join( input );
        },
        cases = {
@@ -128,7 +74,62 @@
                ]
        };
 
-       QUnit.module( 'mediawiki.Title', QUnit.newMwEnvironment( { config: 
config } ) );
+       QUnit.module( 'mediawiki.Title', QUnit.newMwEnvironment( {
+               // mw.Title relies on these three config vars
+               // Restore them after each test run
+               config: {
+                       wgFormattedNamespaces: {
+                               '-2': 'Media',
+                               '-1': 'Special',
+                               0: '',
+                               1: 'Talk',
+                               2: 'User',
+                               3: 'User talk',
+                               4: 'Wikipedia',
+                               5: 'Wikipedia talk',
+                               6: 'File',
+                               7: 'File talk',
+                               8: 'MediaWiki',
+                               9: 'MediaWiki talk',
+                               10: 'Template',
+                               11: 'Template talk',
+                               12: 'Help',
+                               13: 'Help talk',
+                               14: 'Category',
+                               15: 'Category talk',
+                               // testing custom / localized namespace
+                               100: 'Penguins'
+                       },
+                       wgNamespaceIds: {
+                               'media': -2,
+                               'special': -1,
+                               '': 0,
+                               'talk': 1,
+                               'user': 2,
+                               'user_talk': 3,
+                               'wikipedia': 4,
+                               'wikipedia_talk': 5,
+                               'file': 6,
+                               'file_talk': 7,
+                               'mediawiki': 8,
+                               'mediawiki_talk': 9,
+                               'template': 10,
+                               'template_talk': 11,
+                               'help': 12,
+                               'help_talk': 13,
+                               'category': 14,
+                               'category_talk': 15,
+                               'image': 6,
+                               'image_talk': 7,
+                               'project': 4,
+                               'project_talk': 5,
+                               // Testing custom namespaces and aliases
+                               'penguins': 100,
+                               'antarctic_waterfowl': 100
+                       },
+                       wgCaseSensitiveNamespaces: []
+               }
+       } ) );
 
        QUnit.test( 'constructor', cases.invalid.length, function ( assert ) {
                var i, title;
diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js 
b/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js
index 995c1ed..682eb3d 100644
--- a/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js
+++ b/tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js
@@ -12,34 +12,6 @@
                setup: function () {
                        this.originalMwLanguage = mw.language;
 
-                       // Messages that are reused in multiple tests
-                       mw.messages.set( {
-                               // The values for gender are not significant,
-                               // what matters is which of the values is 
choosen by the parser
-                               'gender-msg': '$1: 
{{GENDER:$2|blue|pink|green}}',
-                               'gender-msg-currentuser': 
'{{GENDER:|blue|pink|green}}',
-
-                               'plural-msg': 'Found $1 
{{PLURAL:$1|item|items}}',
-
-                               // Assume the grammar form grammar_case_foo is 
not valid in any language
-                               'grammar-msg': 'Przeszukaj 
{{GRAMMAR:grammar_case_foo|{{SITENAME}}}}',
-
-                               'formatnum-msg': '{{formatnum:$1}}',
-
-                               'portal-url': 'Project:Community portal',
-                               'see-portal-url': '{{Int:portal-url}} is an 
important community page.',
-
-                               'jquerymsg-test-statistics-users': 
'注册[[Special:ListUsers|用户]]',
-
-                               'jquerymsg-test-version-entrypoints-index-php': 
'[https://www.mediawiki.org/wiki/Manual:index.php index.php]',
-
-                               'external-link-replace': 'Foo [$1 bar]'
-                       } );
-
-                       mw.config.set( {
-                               wgArticlePath: '/wiki/$1'
-                       } );
-
                        specialCharactersPageName = '"Who" wants to be a 
millionaire & live on \'Exotic Island\'?';
 
                        expectedListUsers = '注册<a title="Special:ListUsers" 
href="/wiki/Special:ListUsers">用户</a>';
@@ -56,6 +28,32 @@
                },
                teardown: function () {
                        mw.language = this.originalMwLanguage;
+               },
+               config: {
+                       wgArticlePath: '/wiki/$1'
+               },
+               // Messages that are reused in multiple tests
+               messages: {
+                       // The values for gender are not significant,
+                       // what matters is which of the values is choosen by 
the parser
+                       'gender-msg': '$1: {{GENDER:$2|blue|pink|green}}',
+                       'gender-msg-currentuser': '{{GENDER:|blue|pink|green}}',
+
+                       'plural-msg': 'Found $1 {{PLURAL:$1|item|items}}',
+
+                       // Assume the grammar form grammar_case_foo is not 
valid in any language
+                       'grammar-msg': 'Przeszukaj 
{{GRAMMAR:grammar_case_foo|{{SITENAME}}}}',
+
+                       'formatnum-msg': '{{formatnum:$1}}',
+
+                       'portal-url': 'Project:Community portal',
+                       'see-portal-url': '{{Int:portal-url}} is an important 
community page.',
+
+                       'jquerymsg-test-statistics-users': 
'注册[[Special:ListUsers|用户]]',
+
+                       'jquerymsg-test-version-entrypoints-index-php': 
'[https://www.mediawiki.org/wiki/Manual:index.php index.php]',
+
+                       'external-link-replace': 'Foo [$1 bar]'
                }
        } ) );
 
diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.test.js 
b/tests/qunit/suites/resources/mediawiki/mediawiki.test.js
index a9b2f33..90700ca 100644
--- a/tests/qunit/suites/resources/mediawiki/mediawiki.test.js
+++ b/tests/qunit/suites/resources/mediawiki/mediawiki.test.js
@@ -9,26 +9,24 @@
 
        QUnit.module( 'mediawiki', QUnit.newMwEnvironment( {
                setup: function () {
-                       // Messages used in multiple tests
-                       mw.messages.set( {
-                               'other-message': 'Other Message',
-                               
'mediawiki-test-pagetriage-del-talk-page-notify-summary': 'Notifying author of 
deletion nomination for [[$1]]',
-                               'gender-plural-msg': '{{GENDER:$1|he|she|they}} 
{{PLURAL:$2|is|are}} awesome',
-                               'grammar-msg': 'Przeszukaj 
{{GRAMMAR:grammar_case_foo|{{SITENAME}}}}',
-                               'formatnum-msg': '{{formatnum:$1}}',
-                               'int-msg': 'Some {{int:other-message}}',
-                               'mediawiki-test-version-entrypoints-index-php': 
'[https://www.mediawiki.org/wiki/Manual:index.php index.php]',
-                               'external-link-replace': 'Foo [$1 bar]'
-                       } );
-
-                       mw.config.set( {
-                               wgArticlePath: '/wiki/$1',
-
-                               // For formatnum tests
-                               wgUserLanguage: 'en'
-                       } );
-
                        specialCharactersPageName = '"Who" wants to be a 
millionaire & live on \'Exotic Island\'?';
+               },
+               config: {
+                       wgArticlePath: '/wiki/$1',
+
+                       // For formatnum tests
+                       wgUserLanguage: 'en'
+               },
+               // Messages used in multiple tests
+               messages: {
+                       'other-message': 'Other Message',
+                       
'mediawiki-test-pagetriage-del-talk-page-notify-summary': 'Notifying author of 
deletion nomination for [[$1]]',
+                       'gender-plural-msg': '{{GENDER:$1|he|she|they}} 
{{PLURAL:$2|is|are}} awesome',
+                       'grammar-msg': 'Przeszukaj 
{{GRAMMAR:grammar_case_foo|{{SITENAME}}}}',
+                       'formatnum-msg': '{{formatnum:$1}}',
+                       'int-msg': 'Some {{int:other-message}}',
+                       'mediawiki-test-version-entrypoints-index-php': 
'[https://www.mediawiki.org/wiki/Manual:index.php index.php]',
+                       'external-link-replace': 'Foo [$1 bar]'
                }
        } ) );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/132016
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9ac467ad87816c7dc681b62e9b085b643024c15e
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Umherirrender <umherirrender_de...@web.de>
Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to