r89942 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89941‎ | r89942 | r89943 >
Date:00:47, 13 June 2011
Author:krinkle
Status:ok
Tags:
Comment:
Replacing strictEqual-assertion with a more useful QUnit.push that includes the expected and actual values in the html output. This way debugging problems from the TestSwarm will be easier.

This way we end up with:
"Expected: > 100, Result: 99"
instead of:
"Expected: true, Result: false"
which could virtually mean anything (even null, undefined, string, array, you name it)

* Also fixed issue in jquery.colorUtil.js
Modified paths:
  • /trunk/phase3/tests/qunit/suites/resources/jquery/jquery.autoEllipsis.js (modified) (history)
  • /trunk/phase3/tests/qunit/suites/resources/jquery/jquery.colorUtil.js (modified) (history)
  • /trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.js (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.colorUtil.js
@@ -28,7 +28,7 @@
2929 strictEqual( $.colorUtil.getRGB( 'rgba(0,0,0,0)' ), undefined, 'Zero rgba without whitespace' );
3030
3131 deepEqual( $.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (lightGreen)' );
32 - deepEqual( $.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (transparent)' );
 32+ deepEqual( $.colorUtil.getRGB( 'transparent' ), [255, 255, 255], 'Color names (transparent)' );
3333 strictEqual( $.colorUtil.getRGB( 'mediaWiki' ), undefined, 'Inexisting color name' );
3434 });
3535
Index: trunk/phase3/tests/qunit/suites/resources/jquery/jquery.autoEllipsis.js
@@ -23,6 +23,23 @@
2424 test( 'Position right', function() {
2525 expect(3);
2626
 27+ /**
 28+ * Extra QUnit assertions
 29+ * Needed in order to include the expected and actual values in the output.
 30+ * This way we end up with:
 31+ * "Expected: > 100, Result: 99"
 32+ * instead of:
 33+ * "Expected: true, Result: false"
 34+ */
 35+ // Expect numerical value less than or equal to X
 36+ var ltOrEq = function( actual, expected, message ) {
 37+ QUnit.push( actual <= expected, actual, 'less than or equal to ' + expected, message );
 38+ };
 39+ // Expect numerical value greater than X
 40+ var gt = function( actual, expected, message ) {
 41+ QUnit.push( actual > expected, actual, 'greater than ' + expected, message );
 42+ };
 43+
2744 // We need this thing to be visible, so append it to the DOM
2845 var origText = 'This is a really long random string and there is no way it fits in 100 pixels.';
2946 var $wrapper = createWrappedDiv( origText );
@@ -35,7 +52,7 @@
3653
3754 // Check that the text fits by turning on word wrapping
3855 $span.css( 'whiteSpace', 'nowrap' );
39 - strictEqual( $span.width() <= $span.parent().width(), true, "Text fits (span's width is no larger than its parent's width)" );
 56+ ltOrEq( $span.width(), $span.parent().width(), "Text fits (span's width is no larger than its parent's width)" );
4057
4158 // Add one character using scary black magic
4259 var spanText = $span.text();
@@ -44,7 +61,7 @@
4562
4663 // Put this text in the span and verify it doesn't fit
4764 $span.text( spanText );
48 - strictEqual( $span.width() > $span.parent().width(), true, 'Fit is maximal (adding one character makes it not fit any more)' );
 65+ gt( $span.width(), $span.parent().width(), 'Fit is maximal (adding one character makes it not fit any more)' );
4966
5067 // Clean up
5168 $wrapper.remove();
Index: trunk/phase3/tests/qunit/suites/resources/mediawiki/mediawiki.js
@@ -16,6 +16,7 @@
1717
1818 test( 'mw.Map', function() {
1919 expect(15);
 20+
2021 ok( mw.Map, 'mw.Map defined' );
2122
2223 var conf = new mw.Map(),

Status & tagging log