http://www.mediawiki.org/wiki/Special:Code/MediaWiki/88377
Revision: 88377
Author: krinkle
Date: 2011-05-18 17:58:38 +0000 (Wed, 18 May 2011)
Log Message:
-----------
QUnit test suite improvements
* [jquery.autoEllipsis.js] Adding check to verify that span exists and is the
only and direct child
* [mediawiki.js] Deleting window.awesome after the test is ran. This will make
the test suite pass QUnit's "No globals" mode which is useful to detect if a
module introduced an (implied) global variable.
Modified Paths:
--------------
trunk/phase3/resources/test/unit/jquery/jquery.autoEllipsis.js
trunk/phase3/resources/test/unit/mediawiki/mediawiki.js
Modified: trunk/phase3/resources/test/unit/jquery/jquery.autoEllipsis.js
===================================================================
--- trunk/phase3/resources/test/unit/jquery/jquery.autoEllipsis.js
2011-05-18 17:58:11 UTC (rev 88376)
+++ trunk/phase3/resources/test/unit/jquery/jquery.autoEllipsis.js
2011-05-18 17:58:38 UTC (rev 88377)
@@ -25,23 +25,25 @@
var origText = 'This is a really long random string and there is no way
it fits in 100 pixels.';
var $wrapper = createWrappedDiv( origText );
$( 'body' ).append( $wrapper );
- // Autoellipse it
$wrapper.autoEllipsis( { position: 'right' } );
- // Turn on word wrapping
- var $span = $wrapper.find( 'span' );
+
+ // Verify that, and only one, span element was created
+ var $span = $wrapper.find( '> span' );
+ deepEqual( $span.length, 1, 'autoEllipsis wrapped the contents in a
span element' );
+
+ // Check that the text fits by turning on word wrapping
$span.css( 'whiteSpace', 'nowrap' );
-
- // Check that the text fits
- ok( $span.width() <= $span.parent().width(), "text fits (span's width
is no larger than its parent's width)" );
-
+ ok( $span.width() <= $span.parent().width(), "Text fits (span's width
is no larger than its parent's width)" );
+
// Add one character using scary black magic
var spanText = $span.text();
var d = findDivergenceIndex( origText, spanText );
spanText = spanText.substr( 0, d ) + origText[d] + '...';
-
+
// Put this text in the span and verify it doesn't fit
$span.text( spanText );
- ok( $span.width() > $span.parent().width(), "fit is maximal (adding one
character makes it not fit any more)" );
-
+ ok( $span.width() > $span.parent().width(), 'Fit is maximal (adding one
character makes it not fit any more)' );
+
+ // Clean up
$wrapper.remove();
});
Modified: trunk/phase3/resources/test/unit/mediawiki/mediawiki.js
===================================================================
--- trunk/phase3/resources/test/unit/mediawiki/mediawiki.js 2011-05-18
17:58:11 UTC (rev 88376)
+++ trunk/phase3/resources/test/unit/mediawiki/mediawiki.js 2011-05-18
17:58:38 UTC (rev 88377)
@@ -71,6 +71,10 @@
mw.loader.using( 'is.awesome', function(){
start();
deepEqual( window.awesome, true, 'Implementing a module, is the
callback timed properly ?');
+
+ // Clean up
+ delete window.awesome;
+
}, function(){
start();
deepEqual( 'mw.loader.using error callback fired', true,
'Implementing a module, is the callback timed properly ?');
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs