r90728 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90727‎ | r90728 | r90729 >
Date:19:50, 24 June 2011
Author:krinkle
Status:ok
Tags:
Comment:
Adding unit test for span presence in mw.util.addPortletLink
* This is for bug 29567
* Also caching jQuery object while at it and renaming variables to be more descriptive here

Test currently fails (as is supposed to)
Modified paths:
  • /trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.util.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.util.js
@@ -124,7 +124,7 @@
125125 });
126126
127127 test( 'addPortletLink', function() {
128 - expect(5);
 128+ expect(7);
129129
130130 var mwPanel = '<div id="mw-panel" class="noprint">\
131131 <h5>Toolbox</h5>\
@@ -139,25 +139,32 @@
140140 $mwPanel = $(mwPanel).appendTo( 'body' ),
141141 $vectorTabs = $(vectorTabs).appendTo( 'body' );
142142
143 - var A = mw.util.addPortletLink( 'p-tb', 'http://mediawiki.org/wiki/ResourceLoader',
 143+ var tbRL = mw.util.addPortletLink( 'p-tb', 'http://mediawiki.org/wiki/ResourceLoader',
144144 'ResourceLoader', 't-rl', 'More info about ResourceLoader on MediaWiki.org ', 'l' );
145145
146 - ok( $.isDomElement( A ), 'addPortletLink returns a valid DOM Element according to $.isDomElement' );
 146+ ok( $.isDomElement( tbRL ), 'addPortletLink returns a valid DOM Element according to $.isDomElement' );
147147
148 - var B = mw.util.addPortletLink( "p-tb", "http://mediawiki.org/",
149 - "MediaWiki.org", "t-mworg", "Go to MediaWiki.org ", "m", A );
 148+ var tbMW = mw.util.addPortletLink( 'p-tb', 'http://mediawiki.org/',
 149+ 'MediaWiki.org', 't-mworg', 'Go to MediaWiki.org ', 'm', tbRL ),
 150+ $tbMW = $( tbMW );
 151+
150152
151 - equal( $( B ).attr( 'id' ), 't-mworg', 'Link has correct ID set' );
152 - equal( $( B ).closest( '.portlet' ).attr( 'id' ), 'p-tb', 'Link was inserted within correct portlet' );
153 - equal( $( B ).next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing nextnode)' );
 153+ equal( $tbMW.attr( 'id' ), 't-mworg', 'Link has correct ID set' );
 154+ equal( $tbMW.closest( '.portlet' ).attr( 'id' ), 'p-tb', 'Link was inserted within correct portlet' );
 155+ equal( $tbMW.next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing nextnode)' );
154156
155 - var C = mw.util.addPortletLink( "p-tb", "http://mediawiki.org/wiki/RL/DM",
156 - "Default modules", "t-rldm", "List of all default modules ", "d", "#t-rl" );
 157+ var tbRLDM = mw.util.addPortletLink( 'p-tb', 'http://mediawiki.org/wiki/RL/DM',
 158+ 'Default modules', 't-rldm', 'List of all default modules ', 'd', '#t-rl' );
157159
158 - equal( $( C ).next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing CSS selector)' );
 160+ equal( $( tbRLDM ).next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing CSS selector)' );
159161
 162+ var caFoo = mw.util.addPortletLink( 'p-views', '#', 'Foo' );
 163+
 164+ strictEqual( $tbMW.find( 'span').length, 0, 'No <span> element should be added for porlets without vectorTabs class.' );
 165+ strictEqual( $( caFoo ).find( 'span').length, 1, 'A <span> element should be added for porlets with vectorTabs class.' );
 166+
160167 // Clean up
161 - $( [A, B, C] )
 168+ $( [tbRL, tbMW, tbRLDM, caFoo] )
162169 .add( $mwPanel )
163170 .add( $vectorTabs )
164171 .remove();

Follow-up revisions

RevisionCommit summaryAuthorDate
r90729(bug 29567) mw.util.addPortletLink should only wrap link in <span> for "vecto...krinkle19:52, 24 June 2011

Status & tagging log