Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.util.js |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | }); |
126 | 126 | |
127 | 127 | test( 'addPortletLink', function() { |
128 | | - expect(5); |
| 128 | + expect(7); |
129 | 129 | |
130 | 130 | var mwPanel = '<div id="mw-panel" class="noprint">\ |
131 | 131 | <h5>Toolbox</h5>\ |
— | — | @@ -139,25 +139,32 @@ |
140 | 140 | $mwPanel = $(mwPanel).appendTo( 'body' ), |
141 | 141 | $vectorTabs = $(vectorTabs).appendTo( 'body' ); |
142 | 142 | |
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', |
144 | 144 | 'ResourceLoader', 't-rl', 'More info about ResourceLoader on MediaWiki.org ', 'l' ); |
145 | 145 | |
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' ); |
147 | 147 | |
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 | + |
150 | 152 | |
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)' ); |
154 | 156 | |
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' ); |
157 | 159 | |
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)' ); |
159 | 161 | |
| 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 | + |
160 | 167 | // Clean up |
161 | | - $( [A, B, C] ) |
| 168 | + $( [tbRL, tbMW, tbRLDM, caFoo] ) |
162 | 169 | .add( $mwPanel ) |
163 | 170 | .add( $vectorTabs ) |
164 | 171 | .remove(); |