diff --git a/test/vendor/qunit.css b/test/vendor/qunit.css
index 19844c5f..b948bae1 100755
--- a/test/vendor/qunit.css
+++ b/test/vendor/qunit.css
@@ -1,9 +1,9 @@
/**
- * QUnit 1.1.0 - A JavaScript Unit Testing Framework
+ * QUnit v1.5.0 - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
*
- * Copyright (c) 2011 John Resig, Jörn Zaefferer
+ * Copyright (c) 2012 John Resig, Jörn Zaefferer
* Dual licensed under the MIT (MIT-LICENSE.txt)
* or GPL (GPL-LICENSE.txt) licenses.
*/
@@ -54,6 +54,10 @@
color: #fff;
}
+#qunit-header label {
+ display: inline-block;
+}
+
#qunit-banner {
height: 5px;
}
@@ -216,6 +220,9 @@
border-bottom: 1px solid white;
}
+#qunit-testresult .module-name {
+ font-weight: bold;
+}
/** Fixture */
@@ -223,4 +230,6 @@
position: absolute;
top: -10000px;
left: -10000px;
+ width: 1000px;
+ height: 1000px;
}
diff --git a/test/vendor/qunit.js b/test/vendor/qunit.js
index 89c22b36..66dd7215 100755
--- a/test/vendor/qunit.js
+++ b/test/vendor/qunit.js
@@ -1,9 +1,9 @@
/**
- * QUnit 1.1.0 - A JavaScript Unit Testing Framework
+ * QUnit v1.5.0 - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
*
- * Copyright (c) 2011 John Resig, Jörn Zaefferer
+ * Copyright (c) 2012 John Resig, Jörn Zaefferer
* Dual licensed under the MIT (MIT-LICENSE.txt)
* or GPL (GPL-LICENSE.txt) licenses.
*/
@@ -13,23 +13,25 @@
var defined = {
setTimeout: typeof window.setTimeout !== "undefined",
sessionStorage: (function() {
+ var x = "qunit-test-string";
try {
- return !!sessionStorage.getItem;
+ sessionStorage.setItem(x, x);
+ sessionStorage.removeItem(x);
+ return true;
} catch(e) {
return false;
}
- })()
+ }())
};
var testId = 0,
toString = Object.prototype.toString,
hasOwn = Object.prototype.hasOwnProperty;
-var Test = function(name, testName, expected, testEnvironmentArg, async, callback) {
+var Test = function(name, testName, expected, async, callback) {
this.name = name;
this.testName = testName;
this.expected = expected;
- this.testEnvironmentArg = testEnvironmentArg;
this.async = async;
this.callback = callback;
this.assertions = [];
@@ -62,6 +64,10 @@ Test.prototype = {
runLoggingCallbacks( 'moduleStart', QUnit, {
name: this.module
} );
+ } else if (config.autorun) {
+ runLoggingCallbacks( 'moduleStart', QUnit, {
+ name: this.module
+ } );
}
config.current = this;
@@ -69,9 +75,6 @@ Test.prototype = {
setup: function() {},
teardown: function() {}
}, this.moduleTestEnvironment);
- if (this.testEnvironmentArg) {
- extend(this.testEnvironment, this.testEnvironmentArg);
- }
runLoggingCallbacks( 'testStart', QUnit, {
name: this.testName,
@@ -82,18 +85,28 @@ Test.prototype = {
// TODO why??
QUnit.current_testEnvironment = this.testEnvironment;
+ if ( !config.pollution ) {
+ saveGlobal();
+ }
+ if ( config.notrycatch ) {
+ this.testEnvironment.setup.call(this.testEnvironment);
+ return;
+ }
try {
- if ( !config.pollution ) {
- saveGlobal();
- }
-
this.testEnvironment.setup.call(this.testEnvironment);
} catch(e) {
- QUnit.ok( false, "Setup failed on " + this.testName + ": " + e.message );
+ QUnit.pushFailure( "Setup failed on " + this.testName + ": " + e.message, extractStacktrace( e, 1 ) );
}
},
run: function() {
config.current = this;
+
+ var running = id("qunit-testresult");
+
+ if ( running ) {
+ running.innerHTML = "Running: " + this.name;
+ }
+
if ( this.async ) {
QUnit.stop();
}
@@ -105,33 +118,40 @@ Test.prototype = {
try {
this.callback.call(this.testEnvironment);
} catch(e) {
- fail("Test " + this.testName + " died, exception and test follows", e, this.callback);
- QUnit.ok( false, "Died on test #" + (this.assertions.length + 1) + ": " + e.message + " - " + QUnit.jsDump.parse(e) );
+ QUnit.pushFailure( "Died on test #" + (this.assertions.length + 1) + ": " + e.message, extractStacktrace( e, 1 ) );
// else next test will carry the responsibility
saveGlobal();
// Restart the tests if they're blocking
if ( config.blocking ) {
- start();
+ QUnit.start();
}
}
},
teardown: function() {
config.current = this;
- try {
+ if ( config.notrycatch ) {
this.testEnvironment.teardown.call(this.testEnvironment);
- checkPollution();
- } catch(e) {
- QUnit.ok( false, "Teardown failed on " + this.testName + ": " + e.message );
+ return;
+ } else {
+ try {
+ this.testEnvironment.teardown.call(this.testEnvironment);
+ } catch(e) {
+ QUnit.pushFailure( "Teardown failed on " + this.testName + ": " + e.message, extractStacktrace( e, 1 ) );
+ }
}
+ checkPollution();
},
finish: function() {
config.current = this;
if ( this.expected != null && this.expected != this.assertions.length ) {
- QUnit.ok( false, "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run" );
+ QUnit.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run" );
+ } else if ( this.expected == null && !this.assertions.length ) {
+ QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions." );
}
var good = 0, bad = 0,
+ li, i,
tests = id("qunit-tests");
config.stats.all += this.assertions.length;
@@ -140,10 +160,10 @@ Test.prototype = {
if ( tests ) {
var ol = document.createElement("ol");
- for ( var i = 0; i < this.assertions.length; i++ ) {
+ for ( i = 0; i < this.assertions.length; i++ ) {
var assertion = this.assertions[i];
- var li = document.createElement("li");
+ li = document.createElement("li");
li.className = assertion.result ? "pass" : "fail";
li.innerHTML = assertion.message || (assertion.result ? "okay" : "failed");
ol.appendChild( li );
@@ -160,13 +180,13 @@ Test.prototype = {
// store result when possible
if ( QUnit.config.reorder && defined.sessionStorage ) {
if (bad) {
- sessionStorage.setItem("qunit-" + this.module + "-" + this.testName, bad);
+ sessionStorage.setItem("qunit-test-" + this.module + "-" + this.testName, bad);
} else {
- sessionStorage.removeItem("qunit-" + this.module + "-" + this.testName);
+ sessionStorage.removeItem("qunit-test-" + this.module + "-" + this.testName);
}
}
- if (bad == 0) {
+ if (bad === 0) {
ol.style.display = "none";
}
@@ -193,7 +213,7 @@ Test.prototype = {
}
});
- var li = id(this.id);
+ li = id(this.id);
li.className = bad ? "fail" : "pass";
li.removeChild( li.firstChild );
li.appendChild( b );
@@ -201,7 +221,7 @@ Test.prototype = {
li.appendChild( ol );
} else {
- for ( var i = 0; i < this.assertions.length; i++ ) {
+ for ( i = 0; i < this.assertions.length; i++ ) {
if ( !this.assertions[i].result ) {
bad++;
config.stats.bad++;
@@ -210,11 +230,7 @@ Test.prototype = {
}
}
- try {
- QUnit.reset();
- } catch(e) {
- fail("reset() failed, following Test " + this.testName + ", exception and reset fn follows", e, QUnit.reset);
- }
+ QUnit.reset();
runLoggingCallbacks( 'testDone', QUnit, {
name: this.testName,
@@ -246,12 +262,12 @@ Test.prototype = {
});
}
// defer when previous test run passed, if storage is available
- var bad = QUnit.config.reorder && defined.sessionStorage && +sessionStorage.getItem("qunit-" + this.module + "-" + this.testName);
+ var bad = QUnit.config.reorder && defined.sessionStorage && +sessionStorage.getItem("qunit-test-" + this.module + "-" + this.testName);
if (bad) {
run();
} else {
synchronize(run, true);
- };
+ }
}
};
@@ -274,17 +290,12 @@ var QUnit = {
},
test: function(testName, expected, callback, async) {
- var name = '' + testName + '', testEnvironmentArg;
+ var name = '' + escapeInnerText(testName) + '';
if ( arguments.length === 2 ) {
callback = expected;
expected = null;
}
- // is 2nd argument a testEnvironment?
- if ( expected && typeof expected === 'object') {
- testEnvironmentArg = expected;
- expected = null;
- }
if ( config.currentModule ) {
name = '' + config.currentModule + ": " + name;
@@ -294,49 +305,45 @@ var QUnit = {
return;
}
- var test = new Test(name, testName, expected, testEnvironmentArg, async, callback);
+ var test = new Test(name, testName, expected, async, callback);
test.module = config.currentModule;
test.moduleTestEnvironment = config.currentModuleTestEnviroment;
test.queue();
},
- /**
- * 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) {
config.current.expected = asserts;
},
- /**
- * Asserts true.
- * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
- */
- ok: function(a, msg) {
- a = !!a;
+ // Asserts true.
+ // @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" );
+ ok: function(result, msg) {
+ if (!config.current) {
+ throw new Error("ok() assertion outside test context, was " + sourceFromStacktrace(2));
+ }
+ result = !!result;
var details = {
- result: a,
+ result: result,
message: msg
};
- msg = escapeInnerText(msg);
+ msg = escapeInnerText(msg || (result ? "okay" : "failed"));
+ if ( !result ) {
+ var source = sourceFromStacktrace(2);
+ if (source) {
+ details.source = source;
+ msg += '
Source:
' + escapeInnerText(source) + '
';
+ }
+ }
runLoggingCallbacks( 'log', QUnit, details );
config.current.assertions.push({
- result: a,
+ result: result,
message: msg
});
},
- /**
- * Checks that the first two arguments are equal, with an optional message.
- * Prints out both actual and expected values.
- *
- * Prefered to ok( actual == expected, message )
- *
- * @example equal( format("Received {0} bytes.", 2), "Received 2 bytes." );
- *
- * @param Object actual
- * @param Object expected
- * @param String message (optional)
- */
+ // Checks that the first two arguments are equal, with an optional message. Prints out both actual and expected values.
+ // @example equal( format("Received {0} bytes.", 2), "Received 2 bytes." );
equal: function(actual, expected, message) {
QUnit.push(expected == actual, actual, expected, message);
},
@@ -370,7 +377,7 @@ var QUnit = {
}
try {
- block();
+ block.call(config.current.testEnvironment);
} catch (e) {
actual = e;
}
@@ -440,16 +447,21 @@ var QUnit = {
//We want access to the constructor's prototype
(function() {
- function F(){};
+ function F(){}
F.prototype = QUnit;
QUnit = new F();
//Make F QUnit's constructor so that we can add to the prototype later
QUnit.constructor = F;
-})();
+}());
-// Backwards compatibility, deprecated
-QUnit.equals = QUnit.equal;
-QUnit.same = QUnit.deepEqual;
+// deprecated; still export them to window to provide clear error messages
+// next step: remove entirely
+QUnit.equals = function() {
+ QUnit.push(false, false, false, "QUnit.equals has been deprecated since 2009 (e88049a0), use QUnit.equal instead");
+};
+QUnit.same = function() {
+ QUnit.push(false, false, false, "QUnit.same has been deprecated since 2009 (e88049a0), use QUnit.deepEqual instead");
+};
// Maintain internal state
var config = {
@@ -504,17 +516,14 @@ var config = {
config.filter = urlParams.filter;
// Figure out if we're running the tests from a server or not
- QUnit.isLocal = !!(location.protocol === 'file:');
-})();
+ QUnit.isLocal = location.protocol === 'file:';
+}());
// Expose the API as global variables, unless an 'exports'
-// object exists, in that case we assume we're in CommonJS
+// object exists, in that case we assume we're in CommonJS - export everything at the end
if ( typeof exports === "undefined" || typeof require === "undefined" ) {
extend(window, QUnit);
window.QUnit = QUnit;
-} else {
- extend(exports, QUnit);
- exports.QUnit = QUnit;
}
// define these after exposing globals to keep them in these QUnit namespace only
@@ -526,7 +535,7 @@ extend(QUnit, {
extend(config, {
stats: { all: 0, bad: 0 },
moduleStats: { all: 0, bad: 0 },
- started: +new Date,
+ started: +new Date(),
updateRate: 1000,
blocking: false,
autostart: true,
@@ -536,6 +545,16 @@ extend(QUnit, {
semaphore: 0
});
+ var qunit = id( "qunit" );
+ if ( qunit ) {
+ qunit.innerHTML =
+ '
' + escapeInnerText( document.title ) + '
' +
+ '' +
+ '' +
+ '' +
+ '';
+ }
+
var tests = id( "qunit-tests" ),
banner = id( "qunit-banner" ),
result = id( "qunit-testresult" );
@@ -561,11 +580,8 @@ extend(QUnit, {
}
},
- /**
- * Resets the test setup. Useful for tests that modify the DOM.
- *
- * If jQuery is available, uses jQuery's html(), otherwise just innerHTML.
- */
+ // Resets the test setup. Useful for tests that modify the DOM.
+ // If jQuery is available, uses jQuery's html(), otherwise just innerHTML.
reset: function() {
if ( window.jQuery ) {
jQuery( "#qunit-fixture" ).html( config.fixture );
@@ -577,14 +593,8 @@ extend(QUnit, {
}
},
- /**
- * Trigger an event on an element.
- *
- * @example triggerEvent( document.body, "click" );
- *
- * @param DOMElement elem
- * @param String type
- */
+ // Trigger an event on an element.
+ // @example triggerEvent( document.body, "click" );
triggerEvent: function( elem, type, event ) {
if ( document.createEvent ) {
event = document.createEvent("MouseEvents");
@@ -615,19 +625,18 @@ extend(QUnit, {
var type = toString.call( obj ).match(/^\[object\s(.*)\]$/)[1] || '';
switch (type) {
- case 'Number':
- if (isNaN(obj)) {
- return "nan";
- } else {
- return "number";
- }
- case 'String':
- case 'Boolean':
- case 'Array':
- case 'Date':
- case 'RegExp':
- case 'Function':
- return type.toLowerCase();
+ case 'Number':
+ if (isNaN(obj)) {
+ return "nan";
+ }
+ return "number";
+ case 'String':
+ case 'Boolean':
+ case 'Array':
+ case 'Date':
+ case 'RegExp':
+ case 'Function':
+ return type.toLowerCase();
}
if (typeof obj === "object") {
return "object";
@@ -636,6 +645,9 @@ extend(QUnit, {
},
push: function(result, actual, expected, message) {
+ if (!config.current) {
+ throw new Error("assertion outside test context, was " + sourceFromStacktrace());
+ }
var details = {
result: result,
message: message,
@@ -645,21 +657,22 @@ extend(QUnit, {
message = escapeInnerText(message) || (result ? "okay" : "failed");
message = '' + message + "";
- expected = escapeInnerText(QUnit.jsDump.parse(expected));
- actual = escapeInnerText(QUnit.jsDump.parse(actual));
- var output = message + '
Expected:
' + expected + '
';
- if (actual != expected) {
- output += '
Result:
' + actual + '
';
- output += '
Diff:
' + QUnit.diff(expected, actual) +'
';
- }
+ var output = message;
if (!result) {
+ expected = escapeInnerText(QUnit.jsDump.parse(expected));
+ actual = escapeInnerText(QUnit.jsDump.parse(actual));
+ output += '
Expected:
' + expected + '
';
+ if (actual != expected) {
+ output += '
Result:
' + actual + '
';
+ output += '
Diff:
' + QUnit.diff(expected, actual) +'
';
+ }
var source = sourceFromStacktrace();
if (source) {
details.source = source;
output += '