1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-30 08:39:56 +02:00

Update QUnit to v1.14.0.

This commit is contained in:
XhmikosR
2014-03-23 19:49:25 +02:00
parent 4f9270cc20
commit 58ea8a5601
2 changed files with 139 additions and 69 deletions

View File

@@ -1,12 +1,12 @@
/*! /*!
* QUnit 1.13.0 * QUnit 1.14.0
* http://qunitjs.com/ * http://qunitjs.com/
* *
* Copyright 2013 jQuery Foundation and other contributors * Copyright 2013 jQuery Foundation and other contributors
* Released under the MIT license * Released under the MIT license
* http://jquery.org/license * http://jquery.org/license
* *
* Date: 2014-01-04T17:09Z * Date: 2014-01-31T16:40Z
*/ */
/** Font Family and Sizes */ /** Font Family and Sizes */
@@ -32,32 +32,29 @@
#qunit-header { #qunit-header {
padding: 0.5em 0 0.5em 1em; padding: 0.5em 0 0.5em 1em;
color: #8699a4; color: #8699A4;
background-color: #0d3349; background-color: #0D3349;
font-size: 1.5em; font-size: 1.5em;
line-height: 1em; line-height: 1em;
font-weight: normal; font-weight: 400;
border-radius: 5px 5px 0 0; border-radius: 5px 5px 0 0;
-moz-border-radius: 5px 5px 0 0;
-webkit-border-top-right-radius: 5px;
-webkit-border-top-left-radius: 5px;
} }
#qunit-header a { #qunit-header a {
text-decoration: none; text-decoration: none;
color: #c2ccd1; color: #C2CCD1;
} }
#qunit-header a:hover, #qunit-header a:hover,
#qunit-header a:focus { #qunit-header a:focus {
color: #fff; color: #FFF;
} }
#qunit-testrunner-toolbar label { #qunit-testrunner-toolbar label {
display: inline-block; display: inline-block;
padding: 0 .5em 0 .1em; padding: 0 0.5em 0 0.1em;
} }
#qunit-banner { #qunit-banner {
@@ -67,14 +64,14 @@
#qunit-testrunner-toolbar { #qunit-testrunner-toolbar {
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; overflow: hidden;
} }
#qunit-userAgent { #qunit-userAgent {
padding: 0.5em 0 0.5em 2.5em; padding: 0.5em 0 0.5em 2.5em;
background-color: #2b81af; background-color: #2B81AF;
color: #fff; color: #FFF;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
} }
@@ -90,7 +87,7 @@
#qunit-tests li { #qunit-tests li {
padding: 0.4em 0.5em 0.4em 2.5em; padding: 0.4em 0.5em 0.4em 2.5em;
border-bottom: 1px solid #fff; border-bottom: 1px solid #FFF;
list-style-position: inside; list-style-position: inside;
} }
@@ -104,7 +101,7 @@
#qunit-tests li a { #qunit-tests li a {
padding: 0.5em; padding: 0.5em;
color: #c2ccd1; color: #C2CCD1;
text-decoration: none; text-decoration: none;
} }
#qunit-tests li a:hover, #qunit-tests li a:hover,
@@ -121,11 +118,9 @@
margin-top: 0.5em; margin-top: 0.5em;
padding: 0.5em; padding: 0.5em;
background-color: #fff; background-color: #FFF;
border-radius: 5px; border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
} }
.qunit-collapsed { .qunit-collapsed {
@@ -134,13 +129,13 @@
#qunit-tests table { #qunit-tests table {
border-collapse: collapse; border-collapse: collapse;
margin-top: .2em; margin-top: 0.2em;
} }
#qunit-tests th { #qunit-tests th {
text-align: right; text-align: right;
vertical-align: top; vertical-align: top;
padding: 0 .5em 0 0; padding: 0 0.5em 0 0;
} }
#qunit-tests td { #qunit-tests td {
@@ -154,26 +149,26 @@
} }
#qunit-tests del { #qunit-tests del {
background-color: #e0f2be; background-color: #E0F2BE;
color: #374e0c; color: #374E0C;
text-decoration: none; text-decoration: none;
} }
#qunit-tests ins { #qunit-tests ins {
background-color: #ffcaca; background-color: #FFCACA;
color: #500; color: #500;
text-decoration: none; text-decoration: none;
} }
/*** Test Counts */ /*** Test Counts */
#qunit-tests b.counts { color: black; } #qunit-tests b.counts { color: #000; }
#qunit-tests b.passed { color: #5E740B; } #qunit-tests b.passed { color: #5E740B; }
#qunit-tests b.failed { color: #710909; } #qunit-tests b.failed { color: #710909; }
#qunit-tests li li { #qunit-tests li li {
padding: 5px; padding: 5px;
background-color: #fff; background-color: #FFF;
border-bottom: none; border-bottom: none;
list-style-position: inside; list-style-position: inside;
} }
@@ -181,8 +176,8 @@
/*** Passing Styles */ /*** Passing Styles */
#qunit-tests li li.pass { #qunit-tests li li.pass {
color: #3c510c; color: #3C510C;
background-color: #fff; background-color: #FFF;
border-left: 10px solid #C6E746; border-left: 10px solid #C6E746;
} }
@@ -190,7 +185,7 @@
#qunit-tests .pass .test-name { color: #366097; } #qunit-tests .pass .test-name { color: #366097; }
#qunit-tests .pass .test-actual, #qunit-tests .pass .test-actual,
#qunit-tests .pass .test-expected { color: #999999; } #qunit-tests .pass .test-expected { color: #999; }
#qunit-banner.qunit-pass { background-color: #C6E746; } #qunit-banner.qunit-pass { background-color: #C6E746; }
@@ -198,24 +193,21 @@
#qunit-tests li li.fail { #qunit-tests li li.fail {
color: #710909; color: #710909;
background-color: #fff; background-color: #FFF;
border-left: 10px solid #EE5757; border-left: 10px solid #EE5757;
white-space: pre; white-space: pre;
} }
#qunit-tests > li:last-child { #qunit-tests > li:last-child {
border-radius: 0 0 5px 5px; border-radius: 0 0 5px 5px;
-moz-border-radius: 0 0 5px 5px;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
} }
#qunit-tests .fail { color: #000000; background-color: #EE5757; } #qunit-tests .fail { color: #000; background-color: #EE5757; }
#qunit-tests .fail .test-name, #qunit-tests .fail .test-name,
#qunit-tests .fail .module-name { color: #000000; } #qunit-tests .fail .module-name { color: #000; }
#qunit-tests .fail .test-actual { color: #EE5757; } #qunit-tests .fail .test-actual { color: #EE5757; }
#qunit-tests .fail .test-expected { color: green; } #qunit-tests .fail .test-expected { color: #008000; }
#qunit-banner.qunit-fail { background-color: #EE5757; } #qunit-banner.qunit-fail { background-color: #EE5757; }
@@ -225,13 +217,13 @@
#qunit-testresult { #qunit-testresult {
padding: 0.5em 0.5em 0.5em 2.5em; padding: 0.5em 0.5em 0.5em 2.5em;
color: #2b81af; color: #2B81AF;
background-color: #D2E0E6; background-color: #D2E0E6;
border-bottom: 1px solid white; border-bottom: 1px solid #FFF;
} }
#qunit-testresult .module-name { #qunit-testresult .module-name {
font-weight: bold; font-weight: 700;
} }
/** Fixture */ /** Fixture */

View File

@@ -1,12 +1,12 @@
/*! /*!
* QUnit 1.13.0 * QUnit 1.14.0
* http://qunitjs.com/ * http://qunitjs.com/
* *
* Copyright 2013 jQuery Foundation and other contributors * Copyright 2013 jQuery Foundation and other contributors
* Released under the MIT license * Released under the MIT license
* http://jquery.org/license * http://jquery.org/license
* *
* Date: 2014-01-04T17:09Z * Date: 2014-01-31T16:40Z
*/ */
(function( window ) { (function( window ) {
@@ -22,6 +22,7 @@ var QUnit,
// Keep a local reference to Date (GH-283) // Keep a local reference to Date (GH-283)
Date = window.Date, Date = window.Date,
setTimeout = window.setTimeout, setTimeout = window.setTimeout,
clearTimeout = window.clearTimeout,
defined = { defined = {
document: typeof window.document !== "undefined", document: typeof window.document !== "undefined",
setTimeout: typeof window.setTimeout !== "undefined", setTimeout: typeof window.setTimeout !== "undefined",
@@ -238,6 +239,9 @@ config = {
// by default, modify document.title when suite is done // by default, modify document.title when suite is done
altertitle: true, altertitle: true,
// by default, scroll to top of the page when suite is done
scrolltop: true,
// when enabled, all tests must call expect() // when enabled, all tests must call expect()
requireExpects: false, requireExpects: false,
@@ -271,22 +275,26 @@ config = {
// Initialize more QUnit.config and QUnit.urlParams // Initialize more QUnit.config and QUnit.urlParams
(function() { (function() {
var i, var i, current,
location = window.location || { search: "", protocol: "file:" }, location = window.location || { search: "", protocol: "file:" },
params = location.search.slice( 1 ).split( "&" ), params = location.search.slice( 1 ).split( "&" ),
length = params.length, length = params.length,
urlParams = {}, urlParams = {};
current;
if ( params[ 0 ] ) { if ( params[ 0 ] ) {
for ( i = 0; i < length; i++ ) { for ( i = 0; i < length; i++ ) {
current = params[ i ].split( "=" ); current = params[ i ].split( "=" );
current[ 0 ] = decodeURIComponent( current[ 0 ] ); current[ 0 ] = decodeURIComponent( current[ 0 ] );
// allow just a key to turn on a flag, e.g., test.html?noglobals // allow just a key to turn on a flag, e.g., test.html?noglobals
current[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true; current[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true;
if ( urlParams[ current[ 0 ] ] ) {
urlParams[ current[ 0 ] ] = [].concat( urlParams[ current[ 0 ] ], current[ 1 ] );
} else {
urlParams[ current[ 0 ] ] = current[ 1 ]; urlParams[ current[ 0 ] ] = current[ 1 ];
} }
} }
}
QUnit.urlParams = urlParams; QUnit.urlParams = urlParams;
@@ -296,7 +304,16 @@ config = {
// Exact match of the module name // Exact match of the module name
config.module = urlParams.module; config.module = urlParams.module;
config.testNumber = parseInt( urlParams.testNumber, 10 ) || null; config.testNumber = [];
if ( urlParams.testNumber ) {
// Ensure that urlParams.testNumber is an array
urlParams.testNumber = [].concat( urlParams.testNumber );
for ( i = 0; i < urlParams.testNumber.length; i++ ) {
current = urlParams.testNumber[ i ];
config.testNumber.push( parseInt( current, 10 ) );
}
}
// Figure out if we're running the tests from a server or not // Figure out if we're running the tests from a server or not
QUnit.isLocal = location.protocol === "file:"; QUnit.isLocal = location.protocol === "file:";
@@ -558,8 +575,8 @@ 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, var banner, filter, i, j, label, len, main, ol, toolbar, val, selection,
urlConfigCheckboxesContainer, urlConfigCheckboxes, moduleFilter, urlConfigContainer, moduleFilter, userAgent,
numModules = 0, numModules = 0,
moduleNames = [], moduleNames = [],
moduleFilterHtml = "", moduleFilterHtml = "",
@@ -578,17 +595,55 @@ QUnit.load = function() {
if ( typeof val === "string" ) { if ( typeof val === "string" ) {
val = { val = {
id: val, id: val,
label: val, label: val
tooltip: "[no tooltip available]"
}; };
} }
config[ val.id ] = QUnit.urlParams[ val.id ]; config[ val.id ] = QUnit.urlParams[ val.id ];
if ( !val.value || typeof val.value === "string" ) {
urlConfigHtml += "<input id='qunit-urlconfig-" + escapeText( val.id ) + urlConfigHtml += "<input id='qunit-urlconfig-" + escapeText( val.id ) +
"' name='" + escapeText( val.id ) + "' name='" + escapeText( val.id ) +
"' type='checkbox'" + ( config[ val.id ] ? " checked='checked'" : "" ) + "' type='checkbox'" +
( val.value ? " value='" + escapeText( val.value ) + "'" : "" ) +
( config[ val.id ] ? " checked='checked'" : "" ) +
" title='" + escapeText( val.tooltip ) + " title='" + escapeText( val.tooltip ) +
"'><label for='qunit-urlconfig-" + escapeText( val.id ) + "'><label for='qunit-urlconfig-" + escapeText( val.id ) +
"' title='" + escapeText( val.tooltip ) + "'>" + val.label + "</label>"; "' title='" + escapeText( val.tooltip ) + "'>" + val.label + "</label>";
} else {
urlConfigHtml += "<label for='qunit-urlconfig-" + escapeText( val.id ) +
"' title='" + escapeText( val.tooltip ) +
"'>" + val.label +
": </label><select id='qunit-urlconfig-" + escapeText( val.id ) +
"' name='" + escapeText( val.id ) +
"' title='" + escapeText( val.tooltip ) +
"'><option></option>";
selection = false;
if ( QUnit.is( "array", val.value ) ) {
for ( j = 0; j < val.value.length; j++ ) {
urlConfigHtml += "<option value='" + escapeText( val.value[j] ) + "'" +
( config[ val.id ] === val.value[j] ?
(selection = true) && " selected='selected'" :
"" ) +
">" + escapeText( val.value[j] ) + "</option>";
}
} else {
for ( j in val.value ) {
if ( hasOwn.call( val.value, j ) ) {
urlConfigHtml += "<option value='" + escapeText( j ) + "'" +
( config[ val.id ] === j ?
(selection = true) && " selected='selected'" :
"" ) +
">" + escapeText( val.value[j] ) + "</option>";
}
}
}
if ( config[ val.id ] && !selection ) {
urlConfigHtml += "<option value='" + escapeText( config[ val.id ] ) +
"' selected='selected' disabled='disabled'>" +
escapeText( config[ val.id ] ) +
"</option>";
}
urlConfigHtml += "</select>";
}
} }
for ( i in config.modules ) { for ( i in config.modules ) {
if ( config.modules.hasOwnProperty( i ) ) { if ( config.modules.hasOwnProperty( i ) ) {
@@ -665,20 +720,27 @@ QUnit.load = function() {
label.innerHTML = "Hide passed tests"; label.innerHTML = "Hide passed tests";
toolbar.appendChild( label ); toolbar.appendChild( label );
urlConfigCheckboxesContainer = document.createElement("span"); urlConfigContainer = document.createElement("span");
urlConfigCheckboxesContainer.innerHTML = urlConfigHtml; urlConfigContainer.innerHTML = urlConfigHtml;
urlConfigCheckboxes = urlConfigCheckboxesContainer.getElementsByTagName("input");
// For oldIE support: // For oldIE support:
// * Add handlers to the individual elements instead of the container // * Add handlers to the individual elements instead of the container
// * Use "click" instead of "change" // * Use "click" instead of "change" for checkboxes
// * Fallback from event.target to event.srcElement // * Fallback from event.target to event.srcElement
addEvents( urlConfigCheckboxes, "click", function( event ) { addEvents( urlConfigContainer.getElementsByTagName("input"), "click", function( event ) {
var params = {}, var params = {},
target = event.target || event.srcElement; target = event.target || event.srcElement;
params[ target.name ] = target.checked ? true : undefined; params[ target.name ] = target.checked ?
target.defaultValue || true :
undefined;
window.location = QUnit.url( params ); window.location = QUnit.url( params );
}); });
toolbar.appendChild( urlConfigCheckboxesContainer ); addEvents( urlConfigContainer.getElementsByTagName("select"), "change", function( event ) {
var params = {},
target = event.target || event.srcElement;
params[ target.name ] = target.options[ target.selectedIndex ].value || undefined;
window.location = QUnit.url( params );
});
toolbar.appendChild( urlConfigContainer );
if (numModules > 1) { if (numModules > 1) {
moduleFilter = document.createElement( "span" ); moduleFilter = document.createElement( "span" );
@@ -807,7 +869,7 @@ function done() {
} }
// scroll back to top to show results // scroll back to top to show results
if ( window.scrollTo ) { if ( config.scrolltop && window.scrollTo ) {
window.scrollTo(0, 0); window.scrollTo(0, 0);
} }
@@ -832,8 +894,10 @@ function validTest( test ) {
return true; return true;
} }
if ( config.testNumber ) { if ( config.testNumber.length > 0 ) {
return test.testNumber === config.testNumber; if ( inArray( test.testNumber, config.testNumber ) < 0 ) {
return false;
}
} }
if ( module && ( !test.module || test.module.toLowerCase() !== module ) ) { if ( module && ( !test.module || test.module.toLowerCase() !== module ) ) {
@@ -1375,7 +1439,7 @@ Test.prototype = {
total: this.assertions.length, total: this.assertions.length,
runtime: this.runtime, runtime: this.runtime,
// DEPRECATED: this property will be removed in 2.0.0, use runtime instead // DEPRECATED: this property will be removed in 2.0.0, use runtime instead
duration: this.runtime, duration: this.runtime
}); });
QUnit.reset(); QUnit.reset();
@@ -1543,7 +1607,7 @@ assert = QUnit.assert = {
ok = false; ok = false;
// 'expected' is optional // 'expected' is optional
if ( typeof expected === "string" ) { if ( !message && typeof expected === "string" ) {
message = expected; message = expected;
expected = null; expected = null;
} }
@@ -1557,16 +1621,30 @@ assert = QUnit.assert = {
config.current.ignoreGlobalErrors = false; config.current.ignoreGlobalErrors = false;
if ( actual ) { if ( actual ) {
// we don't want to validate thrown error // we don't want to validate thrown error
if ( !expected ) { if ( !expected ) {
ok = true; ok = true;
expectedOutput = null; expectedOutput = null;
// expected is an Error object
} else if ( expected instanceof Error ) {
ok = actual instanceof Error &&
actual.name === expected.name &&
actual.message === expected.message;
// expected is a regexp // expected is a regexp
} else if ( QUnit.objectType( expected ) === "regexp" ) { } else if ( QUnit.objectType( expected ) === "regexp" ) {
ok = expected.test( errorString( actual ) ); ok = expected.test( errorString( actual ) );
// expected is a string
} else if ( QUnit.objectType( expected ) === "string" ) {
ok = expected === errorString( actual );
// expected is a constructor // expected is a constructor
} else if ( actual instanceof expected ) { } else if ( actual instanceof expected ) {
ok = true; ok = true;
// expected is a validation function which returns true is validation passed // expected is a validation function which returns true is validation passed
} else if ( expected.call( {}, actual ) === true ) { } else if ( expected.call( {}, actual ) === true ) {
expectedOutput = null; expectedOutput = null;