11/**
2- * QUnit v1.9 .0 - A JavaScript Unit Testing Framework
2+ * QUnit v1.10 .0 - A JavaScript Unit Testing Framework
33 *
4- * http://docs.jquery. com/QUnit
4+ * http://qunitjs. com
55 *
6- * Copyright (c) 2012 John Resig, Jörn Zaefferer
7- * Dual licensed under the MIT (MIT-LICENSE.txt)
8- * or GPL (GPL-LICENSE.txt) licenses.
6+ * Copyright 2012 jQuery Foundation and other contributors
7+ * Released under the MIT license.
8+ * http://jquery.org/license
99 */
1010
1111( function ( window ) {
@@ -17,6 +17,8 @@ var QUnit,
1717 fileName = ( sourceFromStacktrace ( 0 ) || "" ) . replace ( / ( : \d + ) + \) ? / , "" ) . replace ( / .+ \/ / , "" ) ,
1818 toString = Object . prototype . toString ,
1919 hasOwn = Object . prototype . hasOwnProperty ,
20+ // Keep a local reference to Date (GH-283)
21+ Date = window . Date ,
2022 defined = {
2123 setTimeout : typeof window . setTimeout !== "undefined" ,
2224 sessionStorage : ( function ( ) {
@@ -304,7 +306,8 @@ QUnit = {
304306 // call on start of module test to prepend name to all tests
305307 module : function ( name , testEnvironment ) {
306308 config . currentModule = name ;
307- config . currentModuleTestEnviroment = testEnvironment ;
309+ config . currentModuleTestEnvironment = testEnvironment ;
310+ config . modules [ name ] = true ;
308311 } ,
309312
310313 asyncTest : function ( testName , expected , callback ) {
@@ -336,7 +339,7 @@ QUnit = {
336339 async : async ,
337340 callback : callback ,
338341 module : config . currentModule ,
339- moduleTestEnvironment : config . currentModuleTestEnviroment ,
342+ moduleTestEnvironment : config . currentModuleTestEnvironment ,
340343 stack : sourceFromStacktrace ( 2 )
341344 } ) ;
342345
@@ -349,7 +352,11 @@ QUnit = {
349352
350353 // Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
351354 expect : function ( asserts ) {
352- config . current . expected = asserts ;
355+ if ( arguments . length === 1 ) {
356+ config . current . expected = asserts ;
357+ } else {
358+ return config . current . expected ;
359+ }
353360 } ,
354361
355362 start : function ( count ) {
@@ -415,6 +422,8 @@ QUnit.assert = {
415422
416423 var source ,
417424 details = {
425+ module : config . current . module ,
426+ name : config . current . testName ,
418427 result : result ,
419428 message : msg
420429 } ;
@@ -600,6 +609,9 @@ config = {
600609 }
601610 ] ,
602611
612+ // Set of all modules.
613+ modules : { } ,
614+
603615 // logging callback queues
604616 begin : [ ] ,
605617 done : [ ] ,
@@ -710,17 +722,10 @@ extend( QUnit, {
710722 } ,
711723
712724 // Resets the test setup. Useful for tests that modify the DOM.
713- // If jQuery is available, uses jQuery's html(), otherwise just innerHTML.
714725 reset : function ( ) {
715- var fixture ;
716-
717- if ( window . jQuery ) {
718- jQuery ( "#qunit-fixture" ) . html ( config . fixture ) ;
719- } else {
720- fixture = id ( "qunit-fixture" ) ;
721- if ( fixture ) {
722- fixture . innerHTML = config . fixture ;
723- }
726+ var fixture = id ( "qunit-fixture" ) ;
727+ if ( fixture ) {
728+ fixture . innerHTML = config . fixture ;
724729 }
725730 } ,
726731
@@ -781,6 +786,8 @@ extend( QUnit, {
781786
782787 var output , source ,
783788 details = {
789+ module : config . current . module ,
790+ name : config . current . testName ,
784791 result : result ,
785792 message : message ,
786793 actual : actual ,
@@ -826,6 +833,8 @@ extend( QUnit, {
826833
827834 var output ,
828835 details = {
836+ module : config . current . module ,
837+ name : config . current . testName ,
829838 result : false ,
830839 message : message
831840 } ;
@@ -916,7 +925,9 @@ QUnit.load = function() {
916925 runLoggingCallbacks ( "begin" , QUnit , { } ) ;
917926
918927 // Initialize the config, saving the execution queue
919- var banner , filter , i , label , len , main , ol , toolbar , userAgent , val , urlConfigCheckboxes ,
928+ var banner , filter , i , label , len , main , ol , toolbar , userAgent , val , urlConfigCheckboxes , moduleFilter ,
929+ numModules = 0 ,
930+ moduleFilterHtml = "" ,
920931 urlConfigHtml = "" ,
921932 oldconfig = extend ( { } , config ) ;
922933
@@ -940,6 +951,15 @@ QUnit.load = function() {
940951 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>" ;
941952 }
942953
954+ moduleFilterHtml += "<label for='qunit-modulefilter'>Module: </label><select id='qunit-modulefilter' name='modulefilter'><option value='' " + ( config . module === undefined ? "selected" : "" ) + ">< All Modules ></option>" ;
955+ for ( i in config . modules ) {
956+ if ( config . modules . hasOwnProperty ( i ) ) {
957+ numModules += 1 ;
958+ moduleFilterHtml += "<option value='" + encodeURIComponent ( i ) + "' " + ( config . module === i ? "selected" : "" ) + ">" + i + "</option>" ;
959+ }
960+ }
961+ moduleFilterHtml += "</select>" ;
962+
943963 // `userAgent` initialized at top of scope
944964 userAgent = id ( "qunit-userAgent" ) ;
945965 if ( userAgent ) {
@@ -1002,6 +1022,19 @@ QUnit.load = function() {
10021022 window . location = QUnit . url ( params ) ;
10031023 } ) ;
10041024 toolbar . appendChild ( urlConfigCheckboxes ) ;
1025+
1026+ if ( numModules > 1 ) {
1027+ moduleFilter = document . createElement ( 'span' ) ;
1028+ moduleFilter . setAttribute ( 'id' , 'qunit-modulefilter-container' ) ;
1029+ moduleFilter . innerHTML = moduleFilterHtml ;
1030+ addEvent ( moduleFilter , "change" , function ( ) {
1031+ var selectBox = moduleFilter . getElementsByTagName ( "select" ) [ 0 ] ,
1032+ selectedModule = decodeURIComponent ( selectBox . options [ selectBox . selectedIndex ] . value ) ;
1033+
1034+ window . location = QUnit . url ( { module : ( selectedModule === "" ) ? undefined : selectedModule } ) ;
1035+ } ) ;
1036+ toolbar . appendChild ( moduleFilter ) ;
1037+ }
10051038 }
10061039
10071040 // `main` initialized at top of scope
@@ -1039,9 +1072,9 @@ window.onerror = function ( error, filePath, linerNr ) {
10391072 }
10401073 QUnit . pushFailure ( error , filePath + ":" + linerNr ) ;
10411074 } else {
1042- QUnit . test ( "global failure" , function ( ) {
1075+ QUnit . test ( "global failure" , extend ( function ( ) {
10431076 QUnit . pushFailure ( error , filePath + ":" + linerNr ) ;
1044- } ) ;
1077+ } , { validTest : validTest } ) ) ;
10451078 }
10461079 return false ;
10471080 }
@@ -1108,6 +1141,11 @@ function done() {
11081141 }
11091142 }
11101143
1144+ // scroll back to top to show results
1145+ if ( window . scrollTo ) {
1146+ window . scrollTo ( 0 , 0 ) ;
1147+ }
1148+
11111149 runLoggingCallbacks ( "done" , QUnit , {
11121150 failed : config . stats . bad ,
11131151 passed : passed ,
@@ -1123,6 +1161,12 @@ function validTest( test ) {
11231161 module = config . module && config . module . toLowerCase ( ) ,
11241162 fullName = ( test . module + ": " + test . testName ) . toLowerCase ( ) ;
11251163
1164+ // Internally-generated tests are always valid
1165+ if ( test . callback && test . callback . validTest === validTest ) {
1166+ delete test . callback . validTest ;
1167+ return true ;
1168+ }
1169+
11261170 if ( config . testNumber ) {
11271171 return test . testNumber === config . testNumber ;
11281172 }
@@ -1404,7 +1448,8 @@ QUnit.equiv = (function() {
14041448 a . global === b . global &&
14051449 // (gmi) ...
14061450 a . ignoreCase === b . ignoreCase &&
1407- a . multiline === b . multiline ;
1451+ a . multiline === b . multiline &&
1452+ a . sticky === b . sticky ;
14081453 } ,
14091454
14101455 // - skip when the property is a method of an instance (OOP)
0 commit comments