assert.equal( mw.util.wikiUrlencode( 'Test:A & B/Here' ), 'Test:A_%26_B/Here' );
} );
- QUnit.test( 'wikiGetlink', 4, function ( assert ) {
+ QUnit.test( 'getUrl', 4, function ( assert ) {
// Not part of startUp module
mw.config.set( 'wgArticlePath', '/wiki/$1' );
mw.config.set( 'wgPageName', 'Foobar' );
- var href = mw.util.wikiGetlink( 'Sandbox' );
+ var href = mw.util.getUrl( 'Sandbox' );
assert.equal( href, '/wiki/Sandbox', 'Simple title; Get link for "Sandbox"' );
- href = mw.util.wikiGetlink( 'Foo:Sandbox ? 5+5=10 ! (test)/subpage' );
+ href = mw.util.getUrl( 'Foo:Sandbox ? 5+5=10 ! (test)/subpage' );
assert.equal( href, '/wiki/Foo:Sandbox_%3F_5%2B5%3D10_%21_%28test%29/subpage',
'Advanced title; Get link for "Foo:Sandbox ? 5+5=10 ! (test)/subpage"' );
- href = mw.util.wikiGetlink();
+ href = mw.util.getUrl();
assert.equal( href, '/wiki/Foobar', 'Default title; Get link for current page ("Foobar")' );
- href = mw.util.wikiGetlink( 'Sandbox', { action: 'edit' } );
+ 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' );
} );
* Previously, test elements where invisible to the selector since only
* one element can have a given id.
*/
- QUnit.test( 'addPortletLink', 11, function ( assert ) {
- var pTestTb, pCustom, vectorTabs, tbRL, cuQuux, $cuQuux, tbMW, $tbMW, tbRLDM, caFoo, addedAfter;
+ QUnit.test( 'addPortletLink', 13, function ( assert ) {
+ var pTestTb, pCustom, vectorTabs, tbRL, cuQuux, $cuQuux, tbMW, $tbMW, tbRLDM, caFoo,
+ addedAfter, tbRLDMnonexistentid, tbRLDMemptyjquery;
pTestTb = '\
<div class="portlet" id="p-test-tb">\
addedAfter = mw.util.addPortletLink( 'p-test-tb', '#', 'After foo', 'post-foo', 'After foo', null, $( tbRL ) );
assert.strictEqual( $( addedAfter ).next()[0], tbRL, 'Link is in the correct position (by passing a jQuery object as nextnode)' );
+
+ // test case - nonexistent id as next node
+ tbRLDMnonexistentid = mw.util.addPortletLink( 'p-test-tb', '//mediawiki.org/wiki/RL/DM',
+ 'Default modules', 't-rldm-nonexistent', 'List of all default modules ', 'd', '#t-rl-nonexistent' );
+
+ assert.equal( tbRLDMnonexistentid, $( '#p-test-tb li:last' )[0], 'Nonexistent id as nextnode adds the portlet at end' );
+
+ // test case - empty jquery object as next node
+ tbRLDMemptyjquery = mw.util.addPortletLink( 'p-test-tb', '//mediawiki.org/wiki/RL/DM',
+ 'Default modules', 't-rldm-empty-jquery', 'List of all default modules ', 'd', $( '#t-rl-nonexistent' ) );
+
+ assert.equal( tbRLDMemptyjquery, $( '#p-test-tb li:last' )[0], 'Empty jquery as nextnode adds the portlet at end' );
} );
QUnit.test( 'jsMessage', 1, function ( assert ) {