11/**
2- * QUnit v1.8 .0 - A JavaScript Unit Testing Framework
2+ * QUnit v1.9 .0 - A JavaScript Unit Testing Framework
33 *
44 * http://docs.jquery.com/QUnit
55 *
@@ -403,6 +403,8 @@ QUnit = {
403403QUnit . assert = {
404404 /**
405405 * Asserts rough true-ish result.
406+ * @name ok
407+ * @function
406408 * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
407409 */
408410 ok : function ( result , msg ) {
@@ -437,36 +439,59 @@ QUnit.assert = {
437439 /**
438440 * Assert that the first two arguments are equal, with an optional message.
439441 * Prints out both actual and expected values.
442+ * @name equal
443+ * @function
440444 * @example equal( format( "Received {0} bytes.", 2), "Received 2 bytes.", "format() replaces {0} with next argument" );
441445 */
442446 equal : function ( actual , expected , message ) {
443447 QUnit . push ( expected == actual , actual , expected , message ) ;
444448 } ,
445449
450+ /**
451+ * @name notEqual
452+ * @function
453+ */
446454 notEqual : function ( actual , expected , message ) {
447455 QUnit . push ( expected != actual , actual , expected , message ) ;
448456 } ,
449457
458+ /**
459+ * @name deepEqual
460+ * @function
461+ */
450462 deepEqual : function ( actual , expected , message ) {
451463 QUnit . push ( QUnit . equiv ( actual , expected ) , actual , expected , message ) ;
452464 } ,
453465
<
133E
tr class="diff-line-row">466+ /**
467+ * @name notDeepEqual
468+ * @function
469+ */
454470 notDeepEqual : function ( actual , expected , message ) {
455471 QUnit . push ( ! QUnit . equiv ( actual , expected ) , actual , expected , message ) ;
456472 } ,
457473
474+ /**
475+ * @name strictEqual
476+ * @function
477+ */
458478 strictEqual : function ( actual , expected , message ) {
459479 QUnit . push ( expected === actual , actual , expected , message ) ;
460480 } ,
461481
482+ /**
483+ * @name notStrictEqual
484+ * @function
485+ */
462486 notStrictEqual : function ( actual , expected , message ) {
463487 QUnit . push ( expected !== actual , actual , expected , message ) ;
464488 } ,
465489
466- raises : function ( block , expected , message ) {
490+ throws : function ( block , expected , message ) {
467491 var actual ,
468492 ok = false ;
469493
494+ // 'expected' is optional
470495 if ( typeof expected === "string" ) {
471496 message = expected ;
472497 expected = null ;
@@ -494,18 +519,29 @@ QUnit.assert = {
494519 } else if ( expected . call ( { } , actual ) === true ) {
495520 ok = true ;
496521 }
497- }
498522
499- QUnit . push ( ok , actual , null , message ) ;
523+ QUnit . push ( ok , actual , null , message ) ;
524+ } else {
525+ QUnit . pushFailure ( message , null , 'No exception was thrown.' ) ;
526+ }
500527 }
501528} ;
502529
503- // @deprecated : Kept assertion helpers in root for backwards compatibility
530+ /**
531+ * @deprecate since 1.8.0
532+ * Kept assertion helpers in root for backwards compatibility
533+ */
504534extend ( QUnit , QUnit . assert ) ;
505535
506536/**
507- * @deprecated : Kept for backwards compatibility
508- * next step: remove entirely
537+ * @deprecated since 1.9.0
538+ * Kept global "raises()" for backwards compatibility
539+ */
540+ QUnit . raises = QUnit . assert . throws ;
541+
542+ /**
543+ * @deprecated since 1.0.0, replaced with error pushes since 1.3.0
544+ * Kept to avoid TypeErrors for undefined methods.
509545 */
510546QUnit . equals = function ( ) {
511547 QUnit . push ( false , false , false , "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead" ) ;
@@ -549,7 +585,20 @@ config = {
549585 // when enabled, all tests must call expect()
550586 requireExpects : false ,
551587
552- urlConfig : [ "noglobals" , "notrycatch" ] ,
588+ // add checkboxes that are persisted in the query-string
589+ // when enabled, the id is set to `true` as a `QUnit.config` property
590+ urlConfig : [
591+ {
592+ id : "noglobals" ,
593+ label : "Check for Globals" ,
594+ tooltip : "Enabling this will test if any test introduces new properties on the `window` object. Stored as query-strings."
595+ } ,
596+ {
597+ id : "notrycatch" ,
598+ label : "No try-catch" ,
599+ tooltip : "Enabling this will run tests outside of a try-catch block. Makes debugging exceptions in IE reasonable. Stored as query-strings."
600+ }
601+ ] ,
553602
554603 // logging callback queues
555604 begin : [ ] ,
@@ -770,7 +819,7 @@ extend( QUnit, {
770819 } ) ;
771820 } ,
772821
773- pushFailure : function ( message , source ) {
822+ pushFailure : function ( message , source , actual ) {
774823 if ( ! config . current ) {
775824 throw new Error ( "pushFailure() assertion outside test context, was " + sourceFromStacktrace ( 2 ) ) ;
776825 }
@@ -781,15 +830,23 @@ extend( QUnit, {
781830 message : message
782831 } ;
783832
784- message = escapeInnerText ( message ) || "error" ;
833+ message = escapeInnerText ( message ) || "error" ;
785834 message = "<span class='test-message'>" + message + "</span>" ;
786835 output = message ;
787836
837+ output += "<table>" ;
838+
839+ if ( actual ) {
840+ output += "<tr class='test-actual'><th>Result: </th><td><pre>" + escapeInnerText ( actual ) + "</pre></td></tr>" ;
841+ }
842+
788843 if ( source ) {
789844 details . source = source ;
790- output += "<table>< tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText ( source ) + "</pre></td></tr></table >" ;
845+ output += "<tr class='test-source'><th>Source: </th><td><pre>" + escapeInnerText ( source ) + "</pre></td></tr>" ;
791846 }
792847
848+ output += "</table>" ;
849+
793850 runLoggingCallbacks ( "log" , QUnit , details ) ;
794851
795852 config . current . assertions . push ( {
@@ -859,7 +916,7 @@ QUnit.load = function() {
859916 runLoggingCallbacks ( "begin" , QUnit , { } ) ;
860917
861918 // Initialize the config, saving the execution queue
862- var banner , filter , i , label , len , main , ol , toolbar , userAgent , val ,
919+ var banner , filter , i , label , len , main , ol , toolbar , userAgent , val , urlConfigCheckboxes ,
863920 urlConfigHtml = "" ,
864921 oldconfig = extend ( { } , config ) ;
865922
@@ -872,8 +929,15 @@ QUnit.load = function() {
872929
873930 for ( i = 0 ; i < len ; i ++ ) {
874931 val = config . urlConfig [ i ] ;
875- config [ val ] = QUnit . urlParams [ val ] ;
876- urlConfigHtml += "<label><input name='" + val + "' type='checkbox'" + ( config [ val ] ? " checked='checked'" : "" ) + ">" + v
5D5A
al + "</label>" ;
932+ if ( typeof val === "string" ) {
933+ val = {
934+ id : val ,
935+ label : val ,
936+ tooltip : "[no tooltip available]"
937+ } ;
938+ }
939+ config [ val . id ] = QUnit . urlParams [ val . id ] ;
940+ urlConfigHtml += "<input id='qunit-urlconfig-" + val . id + "' name='" + val . id + "' type='checkbox'" + ( config [ val . id ] ? " checked='checked'" : "" ) + " title='" + val . tooltip + "'><label for='qunit-urlconfig-" + val . id + "' title='" + val . tooltip + "'>" + val . label + "</label>" ;
877941 }
878942
879943 // `userAgent` initialized at top of scope
@@ -885,12 +949,7 @@ QUnit.load = function() {
885949 // `banner` initialized at top of scope
886950 banner = id ( "qunit-header" ) ;
887951 if ( banner ) {
888- banner . innerHTML = "<a href='" + QUnit . url ( { filter : undefined } ) + "'>" + banner . innerHTML + "</a> " + urlConfigHtml ;
889- addEvent ( banner , "change" , function ( event ) {
890- var params = { } ;
891- params [ event . target . name ] = event . target . checked ? true : undefined ;
892- window . location = QUnit . url ( params ) ;
893- } ) ;
952+ banner . innerHTML = "<a href='" + QUnit . url ( { filter : undefined , module : undefined , testNumber : undefined } ) + "'>" + banner . innerHTML + "</a> " ;
894953 }
895954
896955 // `toolbar` initialized at top of scope
@@ -931,8 +990,18 @@ QUnit.load = function() {
931990 // `label` initialized at top of scope
932991 label = document . createElement ( "label" ) ;
933992 label . setAttribute ( "for" , "qunit-filter-pass" ) ;
993+ label . setAttribute ( "title" , "Only show tests and assertons that fail. Stored in sessionStorage." ) ;
934994 label . innerHTML = "Hide passed tests" ;
935995 toolbar . appendChild ( label ) ;
996+
997+ urlConfigCheckboxes = document . createElement ( 'span' ) ;
998+ urlConfigCheckboxes . innerHTML = urlConfigHtml ;
999+ addEvent ( urlConfigCheckboxes , "change" , function ( event ) {
1000+ var params = { } ;
1001+ params [ event . target . name ] = event . target . checked ? true : undefined ;
1002+ window . location = QUnit . url ( params ) ;
1003+ } ) ;
1004+ toolbar . appendChild ( urlConfigCheckboxes ) ;
9361005 }
9371006
9381007 // `main` initialized at top of scope
@@ -1051,14 +1120,14 @@ function done() {
10511120function validTest ( test ) {
10521121 var include ,
10531122 filter = config . filter && config . filter . toLowerCase ( ) ,
1054- module = config . module ,
1123+ module = config . module && config . module . toLowerCase ( ) ,
10551124 fullName = ( test . module + ": " + test . testName ) . toLowerCase ( ) ;
10561125
10571126 if ( config . testNumber ) {
10581127 return test . testNumber === config . testNumber ;
10591128 }
10601129
1061- if ( module && test . module !== module ) {
1130+ if ( module && ( ! test . module || test . module . toLowerCase ( ) !== module ) ) {
10621131 return false ;
10631132 }
10641133
0 commit comments