r90725 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r90724‎ | r90725 | r90726 >
Date:19:35, 24 June 2011
Author:krinkle
Status:ok
Tags:
Comment:
Removing fake html structure from qunit/index.html, instead putting needed nodes in the test suite. Leaving #content due to onload dependancies.

This will all be redundant as soon as phase 2 for JS Unit testing is complete (at which point it will be on an actual wiki page)
Modified paths:
  • /trunk/phase3/tests/qunit/index.html (modified) (history)
  • /trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.util.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/index.html
@@ -85,16 +85,7 @@
8686 <h2 id="qunit-userAgent"></h2>
8787 <ol id="qunit-tests"></ol>
8888
89 -<!-- Rough page structure for scripts needing it (Vector based). -->
9089 <!-- Scripts inserting stuff here shall remove it themselfs! -->
91 -<div id="mw-content">
92 - <div id="bodyContent"></div>
93 - <div id="mw-panel">
94 - <div id="p-tb" class="portal">
95 - <ul class="body">
96 - </ul>
97 - </div>
98 - </div>
99 -</div>
 90+<div id="content"></div>
10091 </body>
10192 </html>
Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.util.js
@@ -49,15 +49,18 @@
5050 test( 'addCSS', function() {
5151 expect(3);
5252
53 - var a = mw.util.addCSS( '#bodyContent { visibility: hidden; }' );
54 - equal( typeof a, 'object', 'addCSS returned an object' );
55 - strictEqual( a.disabled, false, 'property "disabled" is available and set to false' );
 53+ var $testEl = $( '<div>' ).attr( 'id', 'mw-addcsstest' ).appendTo( 'body' );
5654
57 - var $b = $('#bodyContent');
58 - equal( $b.css('visibility'), 'hidden', 'Added style properties are in effect' );
 55+ var style = mw.util.addCSS( '#mw-addcsstest { visibility: hidden; }' );
 56+ equal( typeof style, 'object', 'addCSS returned an object' );
 57+ strictEqual( style.disabled, false, 'property "disabled" is available and set to false' );
5958
 59+ equal( $testEl.css('visibility'), 'hidden', 'Added style properties are in effect' );
 60+
6061 // Clean up
61 - $( a.ownerNode ).remove();
 62+ $( style.ownerNode )
 63+ .add( $testEl )
 64+ .remove();
6265 });
6366
6467 test( 'toggleToc', function() {
@@ -123,8 +126,21 @@
124127 test( 'addPortletLink', function() {
125128 expect(5);
126129
 130+ var mwPanel = '<div id="mw-panel" class="noprint">\
 131+ <h5>Toolbox</h5>\
 132+ <div class="portlet" id="p-tb">\
 133+ <ul class="body"></ul>\
 134+ </div>\
 135+</div>',
 136+ vectorTabs = '<div id="p-views" class="vectorTabs">\
 137+ <h5>Views</h5>\
 138+ <ul></ul>\
 139+</div>',
 140+ $mwPanel = $(mwPanel).appendTo( 'body' ),
 141+ $vectorTabs = $(vectorTabs).appendTo( 'body' );
 142+
127143 var A = mw.util.addPortletLink( 'p-tb', 'http://mediawiki.org/wiki/ResourceLoader',
128 - 'ResourceLoader', 't-rl', 'More info about ResourceLoader on MediaWiki.org ', 'l', '#t-specialpages' );
 144+ 'ResourceLoader', 't-rl', 'More info about ResourceLoader on MediaWiki.org ', 'l' );
129145
130146 ok( $.isDomElement( A ), 'addPortletLink returns a valid DOM Element according to $.isDomElement' );
131147
@@ -132,7 +148,7 @@
133149 "MediaWiki.org", "t-mworg", "Go to MediaWiki.org ", "m", A );
134150
135151 equal( $( B ).attr( 'id' ), 't-mworg', 'Link has correct ID set' );
136 - equal( $( B ).closest( '.portal' ).attr( 'id' ), 'p-tb', 'Link was inserted within correct portlet' );
 152+ equal( $( B ).closest( '.portlet' ).attr( 'id' ), 'p-tb', 'Link was inserted within correct portlet' );
137153 equal( $( B ).next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing nextnode)' );
138154
139155 var C = mw.util.addPortletLink( "p-tb", "http://mediawiki.org/wiki/RL/DM",
@@ -141,7 +157,10 @@
142158 equal( $( C ).next().attr( 'id' ), 't-rl', 'Link is in the correct position (by passing CSS selector)' );
143159
144160 // Clean up
145 - $( [A, B, C] ).remove();
 161+ $( [A, B, C] )
 162+ .add( $mwPanel )
 163+ .add( $vectorTabs )
 164+ .remove();
146165 });
147166
148167 test( 'jsMessage', function() {

Status & tagging log