Home page Forum Wiki Mail Jabber Devel NIX-FILES

AltLUG Git

Git-repositories of Altai Linux User Group

Where we recieve no exception in throws() use a relevant message.
authorAlex J Burke <alex@alexjeffburke.com>
Sun, 24 Jun 2012 16:03:21 +0000 (17:03 +0100)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Fri, 29 Jun 2012 14:56:22 +0000 (07:56 -0700)
Add an additional optional argument to pushFailure() which can be used to
write a message corresponding to what occurred.

In the raises assertion if actual is undefined it means no exception
occurred; since we were expecting one in this case use the modified
pushFailure() to notify the user.

qunit/qunit.js

index b34bc3c..99887c9 100644 (file)
@@ -495,9 +495,11 @@ QUnit.assert = {
                        } else if ( expected.call( {}, actual ) === true ) {
                                ok = true;
                        }
-               }
 
-               QUnit.push( ok, actual, null, message );
+                       QUnit.push( ok, actual, null, message );
+               } else {
+                       QUnit.pushFailure( message, null, 'No exception was thrown.' );
+               }
        }
 };
 
@@ -780,7 +782,7 @@ extend( QUnit, {
                });
        },
 
-       pushFailure: function( message, source ) {
+       pushFailure: function( message, source, actual ) {
                if ( !config.current ) {
                        throw new Error( "pushFailure() assertion outside test context, was " + sourceFromStacktrace(2) );
                }
@@ -791,15 +793,23 @@ extend( QUnit, {
                                message: message
                        };
 
-               message = escapeInnerText(message ) || "error";
+               message = escapeInnerText( message ) || "error";
                message = "<span class='test-message'>" + message + "</span>";
                output = message;
 
+               output += "<table>";
+
+               if ( actual ) {
+                       output += "<tr class='test-actual'><th>Result: </th><td><pre>" + escapeInnerText( actual ) + "</pre></td></tr>";
+               }
+
                if ( source ) {
                        details.source = source;
-                       output += "<table><tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr></table>";
+                       output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText( source ) + "</pre></td></tr>";
                }
 
+               output += "</table>";
+
                runLoggingCallbacks( "log", QUnit, details );
 
                config.current.assertions.push({

Hosting is provided AltSPAHow to use Git
Please direct any questions on jabber alex.wolf@jabber.ru

Valid HTML 4.0 Transitional Valid CSS!

Designer Alexander Wolf