mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 11:57:49 +00:00
Update vendor/qunit-extras.
This commit is contained in:
105
vendor/qunit-extras/qunit-extras.js
vendored
105
vendor/qunit-extras/qunit-extras.js
vendored
@@ -173,6 +173,9 @@
|
|||||||
/** Detects if running in a PhantomJS web page */
|
/** Detects if running in a PhantomJS web page */
|
||||||
var isPhantomPage = typeof context.callPhantom == 'function';
|
var isPhantomPage = typeof context.callPhantom == 'function';
|
||||||
|
|
||||||
|
/** Detects if QUnit Extras should log to the console */
|
||||||
|
var isSilent = document && !isPhantomPage;
|
||||||
|
|
||||||
/** Used to indicate if running in Windows */
|
/** Used to indicate if running in Windows */
|
||||||
var isWindows = /win/i.test(os);
|
var isWindows = /win/i.test(os);
|
||||||
|
|
||||||
@@ -344,12 +347,12 @@
|
|||||||
QUnit.config.extrasData = {
|
QUnit.config.extrasData = {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An array of assertion logs.
|
* An array of details for each log entry.
|
||||||
*
|
*
|
||||||
* @memberOf QUnit.config.extrasData
|
* @memberOf QUnit.config.extrasData
|
||||||
* @type Array
|
* @type Array
|
||||||
*/
|
*/
|
||||||
'logs': []
|
'logEntries': []
|
||||||
};
|
};
|
||||||
|
|
||||||
// add a callback to be triggered when all testing has completed
|
// add a callback to be triggered when all testing has completed
|
||||||
@@ -375,18 +378,21 @@
|
|||||||
config = QUnit.config,
|
config = QUnit.config,
|
||||||
index = -1,
|
index = -1,
|
||||||
length = asserts.length,
|
length = asserts.length,
|
||||||
logs = config.extrasData.logs,
|
entries = config.extrasData.logEntries,
|
||||||
queue = config.queue;
|
queue = config.queue;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
var assert = asserts[index];
|
var assert = asserts[index];
|
||||||
if (!assert.result && this.retries < config.asyncRetries) {
|
if (!assert.result && this.retries < config.asyncRetries) {
|
||||||
|
if (!isSilent) {
|
||||||
|
entries.length -= asserts.length;
|
||||||
|
}
|
||||||
this.retries++;
|
this.retries++;
|
||||||
logs.length = Math.max(0, logs.length - asserts.length);
|
|
||||||
asserts.length = 0;
|
asserts.length = 0;
|
||||||
|
|
||||||
var oldLength = queue.length;
|
var oldLength = queue.length;
|
||||||
this.queue();
|
this.queue();
|
||||||
|
|
||||||
unshift.apply(queue, queue.splice(oldLength, queue.length - oldLength));
|
unshift.apply(queue, queue.splice(oldLength, queue.length - oldLength));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -436,7 +442,7 @@
|
|||||||
/*------------------------------------------------------------------------*/
|
/*------------------------------------------------------------------------*/
|
||||||
|
|
||||||
// add logging extras
|
// add logging extras
|
||||||
if (isPhantomPage || !document) {
|
if (!isSilent) {
|
||||||
// add a callback to be triggered when all testing has completed
|
// add a callback to be triggered when all testing has completed
|
||||||
QUnit.done(function() {
|
QUnit.done(function() {
|
||||||
var ran;
|
var ran;
|
||||||
@@ -478,20 +484,7 @@
|
|||||||
|
|
||||||
// add a callback to be triggered after every assertion
|
// add a callback to be triggered after every assertion
|
||||||
QUnit.log(function(details) {
|
QUnit.log(function(details) {
|
||||||
var expected = details.expected,
|
QUnit.config.extrasData.logEntries.push(details);
|
||||||
result = details.result,
|
|
||||||
type = typeof expected != 'undefined' ? 'EQ' : 'OK';
|
|
||||||
|
|
||||||
var message = [
|
|
||||||
result ? color('green', 'PASS') : color('red', 'FAIL'),
|
|
||||||
color('blue', type),
|
|
||||||
color('blue', details.message || 'ok')
|
|
||||||
];
|
|
||||||
|
|
||||||
if (!result && type == 'EQ') {
|
|
||||||
message.push(color('blue', 'Expected: ' + expected + ', Actual: ' + details.actual));
|
|
||||||
}
|
|
||||||
QUnit.config.extrasData.logs.push(message.join(' | '));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// add a callback to be triggered at the start of every test module
|
// add a callback to be triggered at the start of every test module
|
||||||
@@ -514,32 +507,49 @@
|
|||||||
var config = QUnit.config,
|
var config = QUnit.config,
|
||||||
failures = details.failed,
|
failures = details.failed,
|
||||||
hidepassed = config.hidepassed,
|
hidepassed = config.hidepassed,
|
||||||
logs = config.extrasData.logs,
|
entries = config.extrasData.logEntries.slice(),
|
||||||
testName = details.name;
|
testName = details.name;
|
||||||
|
|
||||||
if (!hidepassed || failures) {
|
config.extrasData.logEntries.length = 0;
|
||||||
logInline('');
|
|
||||||
if (!modulePrinted) {
|
|
||||||
modulePrinted = true;
|
|
||||||
console.log(hr);
|
|
||||||
console.log(color('blue', moduleName));
|
|
||||||
console.log(hr);
|
|
||||||
}
|
|
||||||
console.log(' ' + (failures ? color('red', 'FAIL') : color('green', 'PASS')) + ' - ' + color('blue', testName));
|
|
||||||
|
|
||||||
if (failures) {
|
if (hidepassed && !failures) {
|
||||||
var index = -1,
|
return;
|
||||||
length = logs.length;
|
}
|
||||||
|
logInline('');
|
||||||
while(++index < length) {
|
if (!modulePrinted) {
|
||||||
var message = logs[index];
|
modulePrinted = true;
|
||||||
if (!hidepassed || /^\W*FAIL/.test(message)) {
|
console.log(hr);
|
||||||
console.log(' ' + message);
|
console.log(color('blue', moduleName));
|
||||||
}
|
console.log(hr);
|
||||||
}
|
}
|
||||||
}
|
console.log(' ' + (failures ? color('red', 'FAIL') : color('green', 'PASS')) + ' - ' + color('blue', testName));
|
||||||
|
|
||||||
|
if (!failures) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var index = -1,
|
||||||
|
length = entries.length;
|
||||||
|
|
||||||
|
while(++index < length) {
|
||||||
|
var entry = entries[index];
|
||||||
|
if (hidepassed && entry.result) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var expected = entry.expected,
|
||||||
|
result = entry.result,
|
||||||
|
type = typeof expected != 'undefined' ? 'EQ' : 'OK';
|
||||||
|
|
||||||
|
var message = [
|
||||||
|
result ? color('green', 'PASS') : color('red', 'FAIL'),
|
||||||
|
color('blue', type),
|
||||||
|
color('blue', entry.message || 'ok')
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!result && type == 'EQ') {
|
||||||
|
message.push(color('blue', 'Expected: ' + expected + ', Actual: ' + entry.actual));
|
||||||
|
}
|
||||||
|
console.log(' ' + message.join(' | '));
|
||||||
}
|
}
|
||||||
logs.length = 0;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -553,14 +563,13 @@
|
|||||||
QUnit.jsDump.parsers.object = (function() {
|
QUnit.jsDump.parsers.object = (function() {
|
||||||
var func = QUnit.jsDump.parsers.object;
|
var func = QUnit.jsDump.parsers.object;
|
||||||
return function(object) {
|
return function(object) {
|
||||||
// fork to support Rhino's error objects
|
if (typeof object.rhinoException != 'object') {
|
||||||
if (typeof object.rhinoException == 'object') {
|
return func(object);
|
||||||
return object.name +
|
|
||||||
' { message: "' + object.message +
|
|
||||||
'", fileName: "' + object.fileName +
|
|
||||||
'", lineNumber: ' + object.lineNumber + ' }';
|
|
||||||
}
|
}
|
||||||
return func(object);
|
return object.name +
|
||||||
|
' { message: "' + object.message +
|
||||||
|
'", fileName: "' + object.fileName +
|
||||||
|
'", lineNumber: ' + object.lineNumber + ' }';
|
||||||
};
|
};
|
||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user