From 73231301ae3192c6a32ee927e242b0be9b3d5fae Mon Sep 17 00:00:00 2001 From: Krinkle Date: Mon, 13 Jun 2011 00:47:15 +0000 Subject: [PATCH] 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 --- .../resources/jquery/jquery.autoEllipsis.js | 21 +++++++++++++++++-- .../resources/jquery/jquery.colorUtil.js | 2 +- .../suites/resources/mediawiki/mediawiki.js | 1 + 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/tests/qunit/suites/resources/jquery/jquery.autoEllipsis.js b/tests/qunit/suites/resources/jquery/jquery.autoEllipsis.js index 8a25439158..e7bf032668 100644 --- a/tests/qunit/suites/resources/jquery/jquery.autoEllipsis.js +++ b/tests/qunit/suites/resources/jquery/jquery.autoEllipsis.js @@ -23,6 +23,23 @@ function findDivergenceIndex( a, b ) { test( 'Position right', function() { expect(3); + /** + * Extra QUnit assertions + * Needed in order to include the expected and actual values in the output. + * This way we end up with: + * "Expected: > 100, Result: 99" + * instead of: + * "Expected: true, Result: false" + */ + // Expect numerical value less than or equal to X + var ltOrEq = function( actual, expected, message ) { + QUnit.push( actual <= expected, actual, 'less than or equal to ' + expected, message ); + }; + // Expect numerical value greater than X + var gt = function( actual, expected, message ) { + QUnit.push( actual > expected, actual, 'greater than ' + expected, message ); + }; + // We need this thing to be visible, so append it to the DOM var origText = 'This is a really long random string and there is no way it fits in 100 pixels.'; var $wrapper = createWrappedDiv( origText ); @@ -35,7 +52,7 @@ test( 'Position right', function() { // Check that the text fits by turning on word wrapping $span.css( 'whiteSpace', 'nowrap' ); - strictEqual( $span.width() <= $span.parent().width(), true, "Text fits (span's width is no larger than its parent's width)" ); + ltOrEq( $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(); @@ -44,7 +61,7 @@ test( 'Position right', function() { // Put this text in the span and verify it doesn't fit $span.text( spanText ); - strictEqual( $span.width() > $span.parent().width(), true, 'Fit is maximal (adding one character makes it not fit any more)' ); + gt( $span.width(), $span.parent().width(), 'Fit is maximal (adding one character makes it not fit any more)' ); // Clean up $wrapper.remove(); diff --git a/tests/qunit/suites/resources/jquery/jquery.colorUtil.js b/tests/qunit/suites/resources/jquery/jquery.colorUtil.js index 01965a2f6c..93f12b8295 100644 --- a/tests/qunit/suites/resources/jquery/jquery.colorUtil.js +++ b/tests/qunit/suites/resources/jquery/jquery.colorUtil.js @@ -28,7 +28,7 @@ test( 'getRGB', function() { strictEqual( $.colorUtil.getRGB( 'rgba(0,0,0,0)' ), undefined, 'Zero rgba without whitespace' ); deepEqual( $.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (lightGreen)' ); - deepEqual( $.colorUtil.getRGB( 'lightGreen' ), [144, 238, 144], 'Color names (transparent)' ); + deepEqual( $.colorUtil.getRGB( 'transparent' ), [255, 255, 255], 'Color names (transparent)' ); strictEqual( $.colorUtil.getRGB( 'mediaWiki' ), undefined, 'Inexisting color name' ); }); diff --git a/tests/qunit/suites/resources/mediawiki/mediawiki.js b/tests/qunit/suites/resources/mediawiki/mediawiki.js index 8b65659865..d74f89e96a 100644 --- a/tests/qunit/suites/resources/mediawiki/mediawiki.js +++ b/tests/qunit/suites/resources/mediawiki/mediawiki.js @@ -16,6 +16,7 @@ test( '-- Initial check', function() { test( 'mw.Map', function() { expect(15); + ok( mw.Map, 'mw.Map defined' ); var conf = new mw.Map(), -- 2.20.1