Merge "mediawiki.user: Simplify getRegistration() code branches"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 10 Feb 2015 15:59:40 +0000 (15:59 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 10 Feb 2015 15:59:40 +0000 (15:59 +0000)
resources/src/mediawiki/mediawiki.util.js
tests/qunit/suites/resources/mediawiki/mediawiki.util.test.js

index 0dde873..d202270 100644 (file)
@@ -88,7 +88,7 @@
                /**
                 * Get the link to a page name (relative to `wgServer`),
                 *
-                * @param {string} str Page name
+                * @param {string|null} [str=wgPageName] Page name
                 * @param {Object} [params] A mapping of query parameter names to values,
                 *  e.g. `{ action: 'edit' }`
                 * @return {string} Url of the page with name of `str`
index 7aa9133..3f19a64 100644 (file)
                } );
        } );
 
-       QUnit.test( 'getUrl', 4, function ( assert ) {
+       QUnit.test( 'getUrl', 5, function ( assert ) {
                // Not part of startUp module
                mw.config.set( 'wgArticlePath', '/wiki/$1' );
                mw.config.set( 'wgPageName', 'Foobar' );
 
                var href = mw.util.getUrl( 'Sandbox' );
-               assert.equal( href, '/wiki/Sandbox', 'Simple title; Get link for "Sandbox"' );
+               assert.equal( href, '/wiki/Sandbox', 'simple title' );
 
-               href = mw.util.getUrl( 'Foo:Sandbox ? 5+5=10 ! (test)/subpage' );
-               assert.equal( href, '/wiki/Foo:Sandbox_%3F_5%2B5%3D10_!_(test)/subpage',
-                       'Advanced title; Get link for "Foo:Sandbox ? 5+5=10 ! (test)/subpage"' );
+               href = mw.util.getUrl( 'Foo:Sandbox? 5+5=10! (test)/sub ' );
+               assert.equal( href, '/wiki/Foo:Sandbox%3F_5%2B5%3D10!_(test)/sub_', 'advanced title' );
 
                href = mw.util.getUrl();
-               assert.equal( href, '/wiki/Foobar', 'Default title; Get link for current page ("Foobar")' );
+               assert.equal( href, '/wiki/Foobar', 'default title' );
+
+               href = mw.util.getUrl( null, { action: 'edit' } );
+               assert.equal( href, '/wiki/Foobar?action=edit', 'default title with query string' );
 
                href = mw.util.getUrl( 'Sandbox', { action: 'edit' } );
-               assert.equal( href, '/wiki/Sandbox?action=edit',
-                       'Simple title with query string; Get link for "Sandbox" with action=edit' );
+               assert.equal( href, '/wiki/Sandbox?action=edit', 'simple title with query string' );
        } );
 
        QUnit.test( 'wikiScript', 4, function ( assert ) {