mediawiki.util: Document optional first parameter of getUrl()
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 10 Feb 2015 03:40:07 +0000 (03:40 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Tue, 10 Feb 2015 03:41:19 +0000 (03:41 +0000)
There was already a test for it, but the documentation didn't
reflect it. Elaborate test to also cover case of default title
with additional query parameters.

Change-Id: I147054fc89a1a79c4aa8d3cfa861926515080a94

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 95112f3..3f19a64 100644 (file)
@@ -35,7 +35,7 @@
                } );
        } );
 
-       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' );
@@ -49,6 +49,9 @@
                href = mw.util.getUrl();
                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' );
        } );