http://www.mediawiki.org/wiki/Special:Code/MediaWiki/90725
Revision: 90725
Author: krinkle
Date: 2011-06-24 19:35:21 +0000 (Fri, 24 Jun 2011)
Log Message:
-----------
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
trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.util.js
Modified: trunk/phase3/tests/qunit/index.html
===================================================================
--- trunk/phase3/tests/qunit/index.html 2011-06-24 19:22:50 UTC (rev 90724)
+++ trunk/phase3/tests/qunit/index.html 2011-06-24 19:35:21 UTC (rev 90725)
@@ -85,16 +85,7 @@
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
-<!-- Rough page structure for scripts needing it (Vector based). -->
<!-- Scripts inserting stuff here shall remove it themselfs! -->
-<div id="mw-content">
- <div id="bodyContent"></div>
- <div id="mw-panel">
- <div id="p-tb" class="portal">
- <ul class="body">
- </ul>
- </div>
- </div>
-</div>
+<div id="content"></div>
</body>
</html>
Modified: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.util.js
===================================================================
--- trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.util.js
2011-06-24 19:22:50 UTC (rev 90724)
+++ trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.util.js
2011-06-24 19:35:21 UTC (rev 90725)
@@ -49,15 +49,18 @@
test( 'addCSS', function() {
expect(3);
- var a = mw.util.addCSS( '#bodyContent { visibility: hidden; }' );
- equal( typeof a, 'object', 'addCSS returned an object' );
- strictEqual( a.disabled, false, 'property "disabled" is available and
set to false' );
+ var $testEl = $( '<div>' ).attr( 'id', 'mw-addcsstest' ).appendTo(
'body' );
- var $b = $('#bodyContent');
- equal( $b.css('visibility'), 'hidden', 'Added style properties are in
effect' );
+ var style = mw.util.addCSS( '#mw-addcsstest { visibility: hidden; }' );
+ equal( typeof style, 'object', 'addCSS returned an object' );
+ strictEqual( style.disabled, false, 'property "disabled" is available
and set to false' );
+ equal( $testEl.css('visibility'), 'hidden', 'Added style properties are
in effect' );
+
// Clean up
- $( a.ownerNode ).remove();
+ $( style.ownerNode )
+ .add( $testEl )
+ .remove();
});
test( 'toggleToc', function() {
@@ -123,8 +126,21 @@
test( 'addPortletLink', function() {
expect(5);
+ var mwPanel = '<div id="mw-panel" class="noprint">\
+ <h5>Toolbox</h5>\
+ <div class="portlet" id="p-tb">\
+ <ul class="body"></ul>\
+ </div>\
+</div>',
+ vectorTabs = '<div id="p-views" class="vectorTabs">\
+ <h5>Views</h5>\
+ <ul></ul>\
+</div>',
+ $mwPanel = $(mwPanel).appendTo( 'body' ),
+ $vectorTabs = $(vectorTabs).appendTo( 'body' );
+
var A = mw.util.addPortletLink( 'p-tb',
'http://mediawiki.org/wiki/ResourceLoader',
- 'ResourceLoader', 't-rl', 'More info about ResourceLoader on
MediaWiki.org ', 'l', '#t-specialpages' );
+ 'ResourceLoader', 't-rl', 'More info about ResourceLoader on
MediaWiki.org ', 'l' );
ok( $.isDomElement( A ), 'addPortletLink returns a valid DOM Element
according to $.isDomElement' );
@@ -132,7 +148,7 @@
"MediaWiki.org", "t-mworg", "Go to MediaWiki.org ", "m", A );
equal( $( B ).attr( 'id' ), 't-mworg', 'Link has correct ID set' );
- equal( $( B ).closest( '.portal' ).attr( 'id' ), 'p-tb', 'Link was
inserted within correct portlet' );
+ equal( $( B ).closest( '.portlet' ).attr( 'id' ), 'p-tb', 'Link was
inserted within correct portlet' );
equal( $( B ).next().attr( 'id' ), 't-rl', 'Link is in the correct
position (by passing nextnode)' );
var C = mw.util.addPortletLink( "p-tb",
"http://mediawiki.org/wiki/RL/DM",
@@ -141,7 +157,10 @@
equal( $( C ).next().attr( 'id' ), 't-rl', 'Link is in the correct
position (by passing CSS selector)' );
// Clean up
- $( [A, B, C] ).remove();
+ $( [A, B, C] )
+ .add( $mwPanel )
+ .add( $vectorTabs )
+ .remove();
});
test( 'jsMessage', function() {
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs