Update QUnit to 1.10.0

This commit is contained in:
Jörn Zaefferer 2012-08-30 15:10:52 +02:00
parent 397a421e20
commit 0164db1e0d
2 changed files with 77 additions and 28 deletions

16
external/qunit.css vendored
View File

@ -1,11 +1,11 @@
/** /**
* QUnit v1.9.0 - A JavaScript Unit Testing Framework * QUnit v1.10.0 - A JavaScript Unit Testing Framework
* *
* http://docs.jquery.com/QUnit * http://qunitjs.com
* *
* Copyright (c) 2012 John Resig, Jörn Zaefferer * Copyright 2012 jQuery Foundation and other contributors
* Dual licensed under the MIT (MIT-LICENSE.txt) * Released under the MIT license.
* or GPL (GPL-LICENSE.txt) licenses. * http://jquery.org/license
*/ */
/** Font Family and Sizes */ /** Font Family and Sizes */
@ -20,7 +20,7 @@
/** Resets */ /** Resets */
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult { #qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
@ -67,6 +67,7 @@
padding: 0.5em 0 0.5em 2em; padding: 0.5em 0 0.5em 2em;
color: #5E740B; color: #5E740B;
background-color: #eee; background-color: #eee;
overflow: hidden;
} }
#qunit-userAgent { #qunit-userAgent {
@ -76,6 +77,9 @@
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
} }
#qunit-modulefilter-container {
float: right;
}
/** Tests: Pass/Fail */ /** Tests: Pass/Fail */

83
external/qunit.js vendored
View File

@ -1,11 +1,11 @@
/** /**
* QUnit v1.9.0 - A JavaScript Unit Testing Framework * QUnit v1.10.0 - A JavaScript Unit Testing Framework
* *
* http://docs.jquery.com/QUnit * http://qunitjs.com
* *
* Copyright (c) 2012 John Resig, Jörn Zaefferer * Copyright 2012 jQuery Foundation and other contributors
* Dual licensed under the MIT (MIT-LICENSE.txt) * Released under the MIT license.
* or GPL (GPL-LICENSE.txt) licenses. * http://jquery.org/license
*/ */
(function( window ) { (function( window ) {
@ -17,6 +17,8 @@ var QUnit,
fileName = (sourceFromStacktrace( 0 ) || "" ).replace(/(:\d+)+\)?/, "").replace(/.+\//, ""), fileName = (sourceFromStacktrace( 0 ) || "" ).replace(/(:\d+)+\)?/, "").replace(/.+\//, ""),
toString = Object.prototype.toString, toString = Object.prototype.toString,
hasOwn = Object.prototype.hasOwnProperty, hasOwn = Object.prototype.hasOwnProperty,
// Keep a local reference to Date (GH-283)
Date = window.Date,
defined = { defined = {
setTimeout: typeof window.setTimeout !== "undefined", setTimeout: typeof window.setTimeout !== "undefined",
sessionStorage: (function() { sessionStorage: (function() {
@ -304,7 +306,8 @@ QUnit = {
// call on start of module test to prepend name to all tests // call on start of module test to prepend name to all tests
module: function( name, testEnvironment ) { module: function( name, testEnvironment ) {
config.currentModule = name; config.currentModule = name;
config.currentModuleTestEnviroment = testEnvironment; config.currentModuleTestEnvironment = testEnvironment;
config.modules[name] = true;
}, },
asyncTest: function( testName, expected, callback ) { asyncTest: function( testName, expected, callback ) {
@ -336,7 +339,7 @@ QUnit = {
async: async, async: async,
callback: callback, callback: callback,
module: config.currentModule, module: config.currentModule,
moduleTestEnvironment: config.currentModuleTestEnviroment, moduleTestEnvironment: config.currentModuleTestEnvironment,
stack: sourceFromStacktrace( 2 ) stack: sourceFromStacktrace( 2 )
}); });
@ -349,7 +352,11 @@ QUnit = {
// Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through. // Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through.
expect: function( asserts ) { expect: function( asserts ) {
if (arguments.length === 1) {
config.current.expected = asserts; config.current.expected = asserts;
} else {
return config.current.expected;
}
}, },
start: function( count ) { start: function( count ) {
@ -415,6 +422,8 @@ QUnit.assert = {
var source, var source,
details = { details = {
module: config.current.module,
name: config.current.testName,
result: result, result: result,
message: msg message: msg
}; };
@ -600,6 +609,9 @@ config = {
} }
], ],
// Set of all modules.
modules: {},
// logging callback queues // logging callback queues
begin: [], begin: [],
done: [], done: [],
@ -710,18 +722,11 @@ extend( QUnit, {
}, },
// Resets the test setup. Useful for tests that modify the DOM. // Resets the test setup. Useful for tests that modify the DOM.
// If jQuery is available, uses jQuery's html(), otherwise just innerHTML.
reset: function() { reset: function() {
var fixture; var fixture = id( "qunit-fixture" );
if ( window.jQuery ) {
jQuery( "#qunit-fixture" ).html( config.fixture );
} else {
fixture = id( "qunit-fixture" );
if ( fixture ) { if ( fixture ) {
fixture.innerHTML = config.fixture; fixture.innerHTML = config.fixture;
} }
}
}, },
// Trigger an event on an element. // Trigger an event on an element.
@ -781,6 +786,8 @@ extend( QUnit, {
var output, source, var output, source,
details = { details = {
module: config.current.module,
name: config.current.testName,
result: result, result: result,
message: message, message: message,
actual: actual, actual: actual,
@ -826,6 +833,8 @@ extend( QUnit, {
var output, var output,
details = { details = {
module: config.current.module,
name: config.current.testName,
result: false, result: false,
message: message message: message
}; };
@ -916,7 +925,9 @@ QUnit.load = function() {
runLoggingCallbacks( "begin", QUnit, {} ); runLoggingCallbacks( "begin", QUnit, {} );
// Initialize the config, saving the execution queue // Initialize the config, saving the execution queue
var banner, filter, i, label, len, main, ol, toolbar, userAgent, val, urlConfigCheckboxes, var banner, filter, i, label, len, main, ol, toolbar, userAgent, val, urlConfigCheckboxes, moduleFilter,
numModules = 0,
moduleFilterHtml = "",
urlConfigHtml = "", urlConfigHtml = "",
oldconfig = extend( {}, config ); oldconfig = extend( {}, config );
@ -940,6 +951,15 @@ QUnit.load = function() {
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>"; 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>";
} }
moduleFilterHtml += "<label for='qunit-modulefilter'>Module: </label><select id='qunit-modulefilter' name='modulefilter'><option value='' " + ( config.module === undefined ? "selected" : "" ) + ">< All Modules ></option>";
for ( i in config.modules ) {
if ( config.modules.hasOwnProperty( i ) ) {
numModules += 1;
moduleFilterHtml += "<option value='" + encodeURIComponent(i) + "' " + ( config.module === i ? "selected" : "" ) + ">" + i + "</option>";
}
}
moduleFilterHtml += "</select>";
// `userAgent` initialized at top of scope // `userAgent` initialized at top of scope
userAgent = id( "qunit-userAgent" ); userAgent = id( "qunit-userAgent" );
if ( userAgent ) { if ( userAgent ) {
@ -1002,6 +1022,19 @@ QUnit.load = function() {
window.location = QUnit.url( params ); window.location = QUnit.url( params );
}); });
toolbar.appendChild( urlConfigCheckboxes ); toolbar.appendChild( urlConfigCheckboxes );
if (numModules > 1) {
moduleFilter = document.createElement( 'span' );
moduleFilter.setAttribute( 'id', 'qunit-modulefilter-container' );
moduleFilter.innerHTML = moduleFilterHtml;
addEvent( moduleFilter, "change", function() {
var selectBox = moduleFilter.getElementsByTagName("select")[0],
selectedModule = decodeURIComponent(selectBox.options[selectBox.selectedIndex].value);
window.location = QUnit.url( { module: ( selectedModule === "" ) ? undefined : selectedModule } );
});
toolbar.appendChild(moduleFilter);
}
} }
// `main` initialized at top of scope // `main` initialized at top of scope
@ -1039,9 +1072,9 @@ window.onerror = function ( error, filePath, linerNr ) {
} }
QUnit.pushFailure( error, filePath + ":" + linerNr ); QUnit.pushFailure( error, filePath + ":" + linerNr );
} else { } else {
QUnit.test( "global failure", function() { QUnit.test( "global failure", extend( function() {
QUnit.pushFailure( error, filePath + ":" + linerNr ); QUnit.pushFailure( error, filePath + ":" + linerNr );
}); }, { validTest: validTest } ) );
} }
return false; return false;
} }
@ -1108,6 +1141,11 @@ function done() {
} }
} }
// scroll back to top to show results
if ( window.scrollTo ) {
window.scrollTo(0, 0);
}
runLoggingCallbacks( "done", QUnit, { runLoggingCallbacks( "done", QUnit, {
failed: config.stats.bad, failed: config.stats.bad,
passed: passed, passed: passed,
@ -1123,6 +1161,12 @@ function validTest( test ) {
module = config.module && config.module.toLowerCase(), module = config.module && config.module.toLowerCase(),
fullName = (test.module + ": " + test.testName).toLowerCase(); fullName = (test.module + ": " + test.testName).toLowerCase();
// Internally-generated tests are always valid
if ( test.callback && test.callback.validTest === validTest ) {
delete test.callback.validTest;
return true;
}
if ( config.testNumber ) { if ( config.testNumber ) {
return test.testNumber === config.testNumber; return test.testNumber === config.testNumber;
} }
@ -1404,7 +1448,8 @@ QUnit.equiv = (function() {
a.global === b.global && a.global === b.global &&
// (gmi) ... // (gmi) ...
a.ignoreCase === b.ignoreCase && a.ignoreCase === b.ignoreCase &&
a.multiline === b.multiline; a.multiline === b.multiline &&
a.sticky === b.sticky;
}, },
// - skip when the property is a method of an instance (OOP) // - skip when the property is a method of an instance (OOP)