jasmine.log
in production code.
*/
jasmine.log = function() {
- var spec = jasmine.getEnv().currentSpec;
+ const spec = jasmine.getEnv().currentSpec;
spec.log.apply(spec, arguments);
};
@@ -477,7 +476,7 @@ jasmine.log = function() {
* @param methodName
* @return {jasmine.Spy} a Jasmine spy that can be chained with all spy methods
*/
-var spyOn = function(obj, methodName) {
+const spyOn = function(obj, methodName) {
return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
};
if (isCommonJS) exports.spyOn = spyOn;
@@ -495,7 +494,7 @@ if (isCommonJS) exports.spyOn = spyOn;
* @param {String} desc description of this specification
* @param {Function} func defines the preconditions and expectations of the spec
*/
-var it = function(desc, func) {
+const it = function(desc, func) {
return jasmine.getEnv().it(desc, func);
};
if (isCommonJS) exports.it = it;
@@ -508,7 +507,7 @@ if (isCommonJS) exports.it = it;
* @param {String} desc description of this specification
* @param {Function} func defines the preconditions and expectations of the spec
*/
-var xit = function(desc, func) {
+const xit = function(desc, func) {
return jasmine.getEnv().xit(desc, func);
};
if (isCommonJS) exports.xit = xit;
@@ -522,7 +521,7 @@ if (isCommonJS) exports.xit = xit;
* @param {Object} actual Actual value to test against and expected value
* @return {jasmine.Matchers}
*/
-var expect = function(actual) {
+const expect = function(actual) {
return jasmine.getEnv().currentSpec.expect(actual);
};
if (isCommonJS) exports.expect = expect;
@@ -532,7 +531,7 @@ if (isCommonJS) exports.expect = expect;
*
* @param {Function} func Function that defines part of a jasmine spec.
*/
-var runs = function(func) {
+const runs = function(func) {
jasmine.getEnv().currentSpec.runs(func);
};
if (isCommonJS) exports.runs = runs;
@@ -543,7 +542,7 @@ if (isCommonJS) exports.runs = runs;
* @deprecated Use waitsFor() instead
* @param {Number} timeout milliseconds to wait
*/
-var waits = function(timeout) {
+const waits = function(timeout) {
jasmine.getEnv().currentSpec.waits(timeout);
};
if (isCommonJS) exports.waits = waits;
@@ -555,7 +554,7 @@ if (isCommonJS) exports.waits = waits;
* @param {String} optional_timeoutMessage
* @param {Number} optional_timeout
*/
-var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
+const waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
};
if (isCommonJS) exports.waitsFor = waitsFor;
@@ -567,7 +566,7 @@ if (isCommonJS) exports.waitsFor = waitsFor;
*
* @param {Function} beforeEachFunction
*/
-var beforeEach = function(beforeEachFunction) {
+const beforeEach = function(beforeEachFunction) {
jasmine.getEnv().beforeEach(beforeEachFunction);
};
if (isCommonJS) exports.beforeEach = beforeEach;
@@ -579,7 +578,7 @@ if (isCommonJS) exports.beforeEach = beforeEach;
*
* @param {Function} afterEachFunction
*/
-var afterEach = function(afterEachFunction) {
+const afterEach = function(afterEachFunction) {
jasmine.getEnv().afterEach(afterEachFunction);
};
if (isCommonJS) exports.afterEach = afterEach;
@@ -599,7 +598,7 @@ if (isCommonJS) exports.afterEach = afterEach;
* @param {String} description A string, usually the class under test.
* @param {Function} specDefinitions function that defines several specs.
*/
-var describe = function(description, specDefinitions) {
+const describe = function(description, specDefinitions) {
return jasmine.getEnv().describe(description, specDefinitions);
};
if (isCommonJS) exports.describe = describe;
@@ -610,36 +609,36 @@ if (isCommonJS) exports.describe = describe;
* @param {String} description A string, usually the class under test.
* @param {Function} specDefinitions function that defines several specs.
*/
-var xdescribe = function(description, specDefinitions) {
+const xdescribe = function(description, specDefinitions) {
return jasmine.getEnv().xdescribe(description, specDefinitions);
};
if (isCommonJS) exports.xdescribe = xdescribe;
// Provide the XMLHttpRequest class for IE 5.x-6.x:
-jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
+jasmine.XmlHttpRequest = (typeof XMLHttpRequest == 'undefined') ? function() {
function tryIt(f) {
try {
return f();
- } catch(e) {
+ } catch (e) {
}
return null;
}
- var xhr = tryIt(function() {
- return new ActiveXObject("Msxml2.XMLHTTP.6.0");
+ const xhr = tryIt(function() {
+ return new ActiveXObject('Msxml2.XMLHTTP.6.0');
}) ||
tryIt(function() {
- return new ActiveXObject("Msxml2.XMLHTTP.3.0");
+ return new ActiveXObject('Msxml2.XMLHTTP.3.0');
}) ||
tryIt(function() {
- return new ActiveXObject("Msxml2.XMLHTTP");
+ return new ActiveXObject('Msxml2.XMLHTTP');
}) ||
tryIt(function() {
- return new ActiveXObject("Microsoft.XMLHTTP");
+ return new ActiveXObject('Microsoft.XMLHTTP');
});
- if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
+ if (!xhr) throw new Error('This browser does not support XMLHttpRequest.');
return xhr;
} : XMLHttpRequest;
@@ -659,31 +658,29 @@ jasmine.util.inherit = function(childClass, parentClass) {
/**
* @private
*/
- var subclass = function() {
+ const subclass = function() {
};
subclass.prototype = parentClass.prototype;
childClass.prototype = new subclass();
};
jasmine.util.formatException = function(e) {
- var lineNumber;
+ let lineNumber;
if (e.line) {
lineNumber = e.line;
- }
- else if (e.lineNumber) {
+ } else if (e.lineNumber) {
lineNumber = e.lineNumber;
}
- var file;
+ let file;
if (e.sourceURL) {
file = e.sourceURL;
- }
- else if (e.fileName) {
+ } else if (e.fileName) {
file = e.fileName;
}
- var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
+ let message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
if (file && lineNumber) {
message += ' in ' + file + ' (line ' + lineNumber + ')';
@@ -695,18 +692,18 @@ jasmine.util.formatException = function(e) {
jasmine.util.htmlEscape = function(str) {
if (!str) return str;
return str.replace(/&/g, '&')
- .replace(//g, '>');
+ .replace(//g, '>');
};
jasmine.util.argsToArray = function(args) {
- var arrayOfArgs = [];
- for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
+ const arrayOfArgs = [];
+ for (let i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
return arrayOfArgs;
};
jasmine.util.extend = function(destination, source) {
- for (var property in source) destination[property] = source[property];
+ for (const property in source) destination[property] = source[property];
return destination;
};
@@ -749,9 +746,9 @@ jasmine.Env.prototype.setInterval = jasmine.setInterval;
jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
/**
- * @returns an object containing jasmine version build info, if set.
+ * @return an object containing jasmine version build info, if set.
*/
-jasmine.Env.prototype.version = function () {
+jasmine.Env.prototype.version = function() {
if (jasmine.version_) {
return jasmine.version_;
} else {
@@ -760,33 +757,33 @@ jasmine.Env.prototype.version = function () {
};
/**
- * @returns string containing jasmine version build info, if set.
+ * @return string containing jasmine version build info, if set.
*/
jasmine.Env.prototype.versionString = function() {
if (!jasmine.version_) {
- return "version unknown";
+ return 'version unknown';
}
- var version = this.version();
- var versionString = version.major + "." + version.minor + "." + version.build;
+ const version = this.version();
+ let versionString = version.major + '.' + version.minor + '.' + version.build;
if (version.release_candidate) {
- versionString += ".rc" + version.release_candidate;
+ versionString += '.rc' + version.release_candidate;
}
- versionString += " revision " + version.revision;
+ versionString += ' revision ' + version.revision;
return versionString;
};
/**
- * @returns a sequential integer starting at 0
+ * @return a sequential integer starting at 0
*/
-jasmine.Env.prototype.nextSpecId = function () {
+jasmine.Env.prototype.nextSpecId = function() {
return this.nextSpecId_++;
};
/**
- * @returns a sequential integer starting at 0
+ * @return a sequential integer starting at 0
*/
-jasmine.Env.prototype.nextSuiteId = function () {
+jasmine.Env.prototype.nextSuiteId = function() {
return this.nextSuiteId_++;
};
@@ -803,9 +800,9 @@ jasmine.Env.prototype.execute = function() {
};
jasmine.Env.prototype.describe = function(description, specDefinitions) {
- var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
+ const suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
- var parentSuite = this.currentSuite;
+ const parentSuite = this.currentSuite;
if (parentSuite) {
parentSuite.add(suite);
} else {
@@ -814,15 +811,15 @@ jasmine.Env.prototype.describe = function(description, specDefinitions) {
this.currentSuite = suite;
- var declarationError = null;
+ let declarationError = null;
try {
specDefinitions.call(suite);
- } catch(e) {
+ } catch (e) {
declarationError = e;
}
if (declarationError) {
- this.it("encountered a declaration exception", function() {
+ this.it('encountered a declaration exception', function() {
throw declarationError;
});
}
@@ -840,7 +837,7 @@ jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
}
};
-jasmine.Env.prototype.currentRunner = function () {
+jasmine.Env.prototype.currentRunner = function() {
return this.currentRunner_;
};
@@ -850,18 +847,17 @@ jasmine.Env.prototype.afterEach = function(afterEachFunction) {
} else {
this.currentRunner_.afterEach(afterEachFunction);
}
-
};
jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
return {
execute: function() {
- }
+ },
};
};
jasmine.Env.prototype.it = function(description, func) {
- var spec = new jasmine.Spec(this, this.currentSuite, description);
+ const spec = new jasmine.Spec(this, this.currentSuite, description);
this.currentSuite.add(spec);
this.currentSpec = spec;
@@ -876,25 +872,30 @@ jasmine.Env.prototype.xit = function(desc, func) {
return {
id: this.nextSpecId(),
runs: function() {
- }
+ },
};
};
jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) {
- if (a.source != b.source)
- mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/");
+ if (a.source != b.source) {
+ mismatchValues.push('expected pattern /' + b.source + '/ is not equal to the pattern /' + a.source + '/');
+ }
- if (a.ignoreCase != b.ignoreCase)
- mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier");
+ if (a.ignoreCase != b.ignoreCase) {
+ mismatchValues.push('expected modifier i was' + (b.ignoreCase ? ' ' : ' not ') + 'set and does not equal the origin modifier');
+ }
- if (a.global != b.global)
- mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier");
+ if (a.global != b.global) {
+ mismatchValues.push('expected modifier g was' + (b.global ? ' ' : ' not ') + 'set and does not equal the origin modifier');
+ }
- if (a.multiline != b.multiline)
- mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier");
+ if (a.multiline != b.multiline) {
+ mismatchValues.push('expected modifier m was' + (b.multiline ? ' ' : ' not ') + 'set and does not equal the origin modifier');
+ }
- if (a.sticky != b.sticky)
- mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier");
+ if (a.sticky != b.sticky) {
+ mismatchValues.push('expected modifier y was' + (b.sticky ? ' ' : ' not ') + 'set and does not equal the origin modifier');
+ }
return (mismatchValues.length === 0);
};
@@ -907,29 +908,29 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
a.__Jasmine_been_here_before__ = b;
b.__Jasmine_been_here_before__ = a;
- var hasKey = function(obj, keyName) {
+ const hasKey = function(obj, keyName) {
return obj !== null && obj[keyName] !== jasmine.undefined;
};
for (var property in b) {
if (!hasKey(a, property) && hasKey(b, property)) {
- mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
+ mismatchKeys.push('expected has key \'' + property + '\', but missing from actual.');
}
}
for (property in a) {
if (!hasKey(b, property) && hasKey(a, property)) {
- mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
+ mismatchKeys.push('expected missing key \'' + property + '\', but present in actual.');
}
}
for (property in b) {
if (property == '__Jasmine_been_here_before__') continue;
if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {
- mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.");
+ mismatchValues.push('\'' + property + '\' was \'' + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + '\' in expected, but was \'' + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + '\' in actual.');
}
}
if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) {
- mismatchValues.push("arrays were not the same length");
+ mismatchValues.push('arrays were not the same length');
}
delete a.__Jasmine_been_here_before__;
@@ -941,9 +942,9 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
mismatchKeys = mismatchKeys || [];
mismatchValues = mismatchValues || [];
- for (var i = 0; i < this.equalityTesters_.length; i++) {
- var equalityTester = this.equalityTesters_[i];
- var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
+ for (let i = 0; i < this.equalityTesters_.length; i++) {
+ const equalityTester = this.equalityTesters_[i];
+ const result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
if (result !== jasmine.undefined) return result;
}
@@ -989,17 +990,17 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
return this.compareRegExps_(a, b, mismatchKeys, mismatchValues);
}
- if (typeof a === "object" && typeof b === "object") {
+ if (typeof a === 'object' && typeof b === 'object') {
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
}
- //Straight check
+ // Straight check
return (a === b);
};
jasmine.Env.prototype.contains_ = function(haystack, needle) {
if (jasmine.isArray_(haystack)) {
- for (var i = 0; i < haystack.length; i++) {
+ for (let i = 0; i < haystack.length; i++) {
if (this.equals_(haystack[i], needle)) return true;
}
return false;
@@ -1017,27 +1018,27 @@ jasmine.Env.prototype.addEqualityTester = function(equalityTester) {
jasmine.Reporter = function() {
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.Reporter.prototype.reportRunnerStarting = function(runner) {
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.Reporter.prototype.reportSpecStarting = function(spec) {
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.Reporter.prototype.reportSpecResults = function(spec) {
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.Reporter.prototype.log = function(str) {
};
@@ -1058,8 +1059,7 @@ jasmine.Block = function(env, func, spec) {
jasmine.Block.prototype.execute = function(onComplete) {
if (!jasmine.CATCH_EXCEPTIONS) {
this.func.apply(this.spec);
- }
- else {
+ } else {
try {
this.func.apply(this.spec);
} catch (e) {
@@ -1081,9 +1081,9 @@ jasmine.JsApiReporter = function() {
jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
this.started = true;
- var suites = runner.topLevelSuites();
- for (var i = 0; i < suites.length; i++) {
- var suite = suites[i];
+ const suites = runner.topLevelSuites();
+ for (let i = 0; i < suites.length; i++) {
+ const suite = suites[i];
this.suites_.push(this.summarize_(suite));
}
};
@@ -1093,17 +1093,17 @@ jasmine.JsApiReporter.prototype.suites = function() {
};
jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
- var isSuite = suiteOrSpec instanceof jasmine.Suite;
- var summary = {
+ const isSuite = suiteOrSpec instanceof jasmine.Suite;
+ const summary = {
id: suiteOrSpec.id,
name: suiteOrSpec.description,
type: isSuite ? 'suite' : 'spec',
- children: []
+ children: [],
};
-
+
if (isSuite) {
- var children = suiteOrSpec.children();
- for (var i = 0; i < children.length; i++) {
+ const children = suiteOrSpec.children();
+ for (let i = 0; i < children.length; i++) {
summary.children.push(this.summarize_(children[i]));
}
}
@@ -1118,55 +1118,55 @@ jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) {
return this.results_[specId];
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) {
this.finished = true;
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) {
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
this.results_[spec.id] = {
messages: spec.results().getItems(),
- result: spec.results().failedCount > 0 ? "failed" : "passed"
+ result: spec.results().failedCount > 0 ? 'failed' : 'passed',
};
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.JsApiReporter.prototype.log = function(str) {
};
-jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
- var results = {};
- for (var i = 0; i < specIds.length; i++) {
- var specId = specIds[i];
+jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds) {
+ const results = {};
+ for (let i = 0; i < specIds.length; i++) {
+ const specId = specIds[i];
results[specId] = this.summarizeResult_(this.results_[specId]);
}
return results;
};
-jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
- var summaryMessages = [];
- var messagesLength = result.messages.length;
- for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
- var resultMessage = result.messages[messageIndex];
+jasmine.JsApiReporter.prototype.summarizeResult_ = function(result) {
+ const summaryMessages = [];
+ const messagesLength = result.messages.length;
+ for (let messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
+ const resultMessage = result.messages[messageIndex];
summaryMessages.push({
text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined,
passed: resultMessage.passed ? resultMessage.passed() : true,
type: resultMessage.type,
message: resultMessage.message,
trace: {
- stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
- }
+ stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined,
+ },
});
}
return {
- result : result.result,
- messages : summaryMessages
+ result: result.result,
+ messages: summaryMessages,
};
};
@@ -1186,26 +1186,26 @@ jasmine.Matchers = function(env, actual, spec, opt_isNot) {
// todo: @deprecated as of Jasmine 0.11, remove soon [xw]
jasmine.Matchers.pp = function(str) {
- throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!");
+ throw new Error('jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!');
};
// todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw]
jasmine.Matchers.prototype.report = function(result, failing_message, details) {
- throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs");
+ throw new Error('As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs');
};
jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) {
- for (var methodName in prototype) {
+ for (const methodName in prototype) {
if (methodName == 'report') continue;
- var orig = prototype[methodName];
+ const orig = prototype[methodName];
matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
}
};
jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
return function() {
- var matcherArgs = jasmine.util.argsToArray(arguments);
- var result = matcherFunction.apply(this, arguments);
+ const matcherArgs = jasmine.util.argsToArray(arguments);
+ let result = matcherFunction.apply(this, arguments);
if (this.isNot) {
result = !result;
@@ -1213,7 +1213,7 @@ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
if (this.reportWasCalled_) return result;
- var message;
+ let message;
if (!result) {
if (this.message) {
message = this.message.apply(this, arguments);
@@ -1221,23 +1221,25 @@ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
message = message[this.isNot ? 1 : 0];
}
} else {
- var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
- message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate;
+ const englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) {
+ return ' ' + s.toLowerCase();
+ });
+ message = 'Expected ' + jasmine.pp(this.actual) + (this.isNot ? ' not ' : ' ') + englishyPredicate;
if (matcherArgs.length > 0) {
- for (var i = 0; i < matcherArgs.length; i++) {
- if (i > 0) message += ",";
- message += " " + jasmine.pp(matcherArgs[i]);
+ for (let i = 0; i < matcherArgs.length; i++) {
+ if (i > 0) message += ',';
+ message += ' ' + jasmine.pp(matcherArgs[i]);
}
}
- message += ".";
+ message += '.';
}
}
- var expectationResult = new jasmine.ExpectationResult({
+ const expectationResult = new jasmine.ExpectationResult({
matcherName: matcherName,
passed: result,
expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],
actual: this.actual,
- message: message
+ message: message,
});
this.spec.addMatcherResult(expectationResult);
return jasmine.undefined;
@@ -1245,8 +1247,6 @@ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
};
-
-
/**
* toBe: compares the actual to the expected using ===
* @param expected
@@ -1326,11 +1326,11 @@ jasmine.Matchers.prototype.toBeNull = function() {
* Matcher that compares the actual to NaN.
*/
jasmine.Matchers.prototype.toBeNaN = function() {
- this.message = function() {
- return [ "Expected " + jasmine.pp(this.actual) + " to be NaN." ];
- };
+ this.message = function() {
+ return ['Expected ' + jasmine.pp(this.actual) + ' to be NaN.'];
+ };
- return (this.actual !== this.actual);
+ return (this.actual !== this.actual);
};
/**
@@ -1363,8 +1363,8 @@ jasmine.Matchers.prototype.toHaveBeenCalled = function() {
this.message = function() {
return [
- "Expected spy " + this.actual.identity + " to have been called.",
- "Expected spy " + this.actual.identity + " not to have been called."
+ 'Expected spy ' + this.actual.identity + ' to have been called.',
+ 'Expected spy ' + this.actual.identity + ' not to have been called.',
];
};
@@ -1390,8 +1390,8 @@ jasmine.Matchers.prototype.wasNotCalled = function() {
this.message = function() {
return [
- "Expected spy " + this.actual.identity + " to not have been called.",
- "Expected spy " + this.actual.identity + " to have been called."
+ 'Expected spy ' + this.actual.identity + ' to not have been called.',
+ 'Expected spy ' + this.actual.identity + ' to have been called.',
];
};
@@ -1405,17 +1405,17 @@ jasmine.Matchers.prototype.wasNotCalled = function() {
*
*/
jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
- var expectedArgs = jasmine.util.argsToArray(arguments);
+ const expectedArgs = jasmine.util.argsToArray(arguments);
if (!jasmine.isSpy(this.actual)) {
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
}
this.message = function() {
- var invertedMessage = "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was.";
- var positiveMessage = "";
+ const invertedMessage = 'Expected spy ' + this.actual.identity + ' not to have been called with ' + jasmine.pp(expectedArgs) + ' but it was.';
+ let positiveMessage = '';
if (this.actual.callCount === 0) {
- positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";
+ positiveMessage = 'Expected spy ' + this.actual.identity + ' to have been called with ' + jasmine.pp(expectedArgs) + ' but it was never called.';
} else {
- positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but actual calls were " + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '')
+ positiveMessage = 'Expected spy ' + this.actual.identity + ' to have been called with ' + jasmine.pp(expectedArgs) + ' but actual calls were ' + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '');
}
return [positiveMessage, invertedMessage];
};
@@ -1428,15 +1428,15 @@ jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.prototype.toHaveBeen
/** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */
jasmine.Matchers.prototype.wasNotCalledWith = function() {
- var expectedArgs = jasmine.util.argsToArray(arguments);
+ const expectedArgs = jasmine.util.argsToArray(arguments);
if (!jasmine.isSpy(this.actual)) {
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
}
this.message = function() {
return [
- "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
- "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
+ 'Expected spy not to have been called with ' + jasmine.pp(expectedArgs) + ' but it was',
+ 'Expected spy to have been called with ' + jasmine.pp(expectedArgs) + ' but it was',
];
};
@@ -1490,8 +1490,8 @@ jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
* @param {String} [expected]
*/
jasmine.Matchers.prototype.toThrow = function(expected) {
- var result = false;
- var exception;
+ let result = false;
+ let exception;
if (typeof this.actual != 'function') {
throw new Error('Actual is not a function');
}
@@ -1504,13 +1504,13 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
}
- var not = this.isNot ? "not " : "";
+ const not = this.isNot ? 'not ' : '';
this.message = function() {
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
- return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
+ return ['Expected function ' + not + 'to throw', expected ? expected.message || expected : 'an exception', ', but it threw', exception.message || exception].join(' ');
} else {
- return "Expected function to throw an exception.";
+ return 'Expected function to throw an exception.';
}
};
@@ -1545,7 +1545,7 @@ jasmine.Matchers.Any.prototype.jasmineToString = function() {
return '%s
%s
%e', str)); - } + runner.on('suite', function(suite) { + if (suite.root) return; - // toggle code - // TODO: defer - if (!test.pending) { - var h2 = el.getElementsByTagName('h2')[0]; + // suite + const url = self.suiteURL(suite); + const el = fragment('
%e
', utils.clean(test.fn.toString()));
- el.appendChild(pre);
- pre.style.display = 'none';
- }
+ runner.on('suite end', function(suite) {
+ if (suite.root) return;
+ stack.shift();
+ });
+
+ runner.on('fail', function(test, err) {
+ if ('hook' == test.type) runner.emit('test end', test);
+ });
+
+ runner.on('test end', function(test) {
+ // TODO: add to stats
+ const percent = stats.tests / this.total * 100 | 0;
+ if (progress) progress.update(percent).draw(ctx);
+
+ // update stats
+ const ms = new Date - stats.start;
+ text(passes, stats.passes);
+ text(failures, stats.failures);
+ text(duration, (ms / 1000).toFixed(2));
+
+ // test
+ if ('passed' == test.state) {
+ const url = self.testURL(test);
+ var el = fragment('%e', str)); + } - // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack. - if (stack[0]) stack[0].appendChild(el); - }); -} + // toggle code + // TODO: defer + if (!test.pending) { + const h2 = el.getElementsByTagName('h2')[0]; -/** + on(h2, 'click', function() { + pre.style.display = 'none' == pre.style.display ? + 'block' : + 'none'; + }); + + var pre = fragment('
%e
', utils.clean(test.fn.toString()));
+ el.appendChild(pre);
+ pre.style.display = 'none';
+ }
+
+ // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.
+ if (stack[0]) stack[0].appendChild(el);
+ });
+ }
+
+ /**
* Provide suite URL
*
* @param {Object} [suite]
*/
-HTML.prototype.suiteURL = function(suite){
- return '?grep=' + encodeURIComponent(suite.fullTitle());
-};
+ HTML.prototype.suiteURL = function(suite) {
+ return '?grep=' + encodeURIComponent(suite.fullTitle());
+ };
-/**
+ /**
* Provide test URL
*
* @param {Object} [test]
*/
-HTML.prototype.testURL = function(test){
- return '?grep=' + encodeURIComponent(test.fullTitle());
-};
+ HTML.prototype.testURL = function(test) {
+ return '?grep=' + encodeURIComponent(test.fullTitle());
+ };
-/**
+ /**
* Display error `msg`.
*/
-function error(msg) {
- document.body.appendChild(fragment('Expected: | " + expected + " |
---|---|
Result: | " + actual + " |
Diff: | " + QUnit.diff( expected, actual ) + " |
Source: | " + escapeText( source ) + " |
Result: | " + escapeText( actual ) + " |
---|---|
Source: | " + escapeText( source ) + " |
Expected: | ' + expected + ' |
---|---|
Result: | ' + actual + ' |
Diff: | ' + QUnit.diff( expected, actual ) + ' |
Source: | ' + escapeText( source ) + ' |
Result: | ' + escapeText( actual ) + ' |
---|---|
Source: | ' + escapeText( source ) + ' |
Source: | " +
+ 'ok': function( result, msg ) {
+ if ( !config.current ) {
+ throw new Error( 'ok() assertion outside test context, was ' + sourceFromStacktrace(2) );
+ }
+ result = !!result;
+ msg = msg || ( result ? 'okay' : 'failed' );
+
+ let source;
+ const details = {
+ module: config.current.module,
+ name: config.current.testName,
+ result: result,
+ message: msg,
+ };
+
+ msg = ' ';
+
+ if ( !result ) {
+ source = sourceFromStacktrace( 2 );
+ if ( source ) {
+ details.source = source;
+ msg += '
|
---|
jasmine.log
in production code.
*/
jasmine.log = function() {
- var spec = jasmine.getEnv().currentSpec;
+ const spec = jasmine.getEnv().currentSpec;
spec.log.apply(spec, arguments);
};
@@ -477,7 +476,7 @@ jasmine.log = function() {
* @param methodName
* @return {jasmine.Spy} a Jasmine spy that can be chained with all spy methods
*/
-var spyOn = function(obj, methodName) {
+const spyOn = function(obj, methodName) {
return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
};
if (isCommonJS) exports.spyOn = spyOn;
@@ -495,7 +494,7 @@ if (isCommonJS) exports.spyOn = spyOn;
* @param {String} desc description of this specification
* @param {Function} func defines the preconditions and expectations of the spec
*/
-var it = function(desc, func) {
+const it = function(desc, func) {
return jasmine.getEnv().it(desc, func);
};
if (isCommonJS) exports.it = it;
@@ -508,7 +507,7 @@ if (isCommonJS) exports.it = it;
* @param {String} desc description of this specification
* @param {Function} func defines the preconditions and expectations of the spec
*/
-var xit = function(desc, func) {
+const xit = function(desc, func) {
return jasmine.getEnv().xit(desc, func);
};
if (isCommonJS) exports.xit = xit;
@@ -522,7 +521,7 @@ if (isCommonJS) exports.xit = xit;
* @param {Object} actual Actual value to test against and expected value
* @return {jasmine.Matchers}
*/
-var expect = function(actual) {
+const expect = function(actual) {
return jasmine.getEnv().currentSpec.expect(actual);
};
if (isCommonJS) exports.expect = expect;
@@ -532,7 +531,7 @@ if (isCommonJS) exports.expect = expect;
*
* @param {Function} func Function that defines part of a jasmine spec.
*/
-var runs = function(func) {
+const runs = function(func) {
jasmine.getEnv().currentSpec.runs(func);
};
if (isCommonJS) exports.runs = runs;
@@ -543,7 +542,7 @@ if (isCommonJS) exports.runs = runs;
* @deprecated Use waitsFor() instead
* @param {Number} timeout milliseconds to wait
*/
-var waits = function(timeout) {
+const waits = function(timeout) {
jasmine.getEnv().currentSpec.waits(timeout);
};
if (isCommonJS) exports.waits = waits;
@@ -555,7 +554,7 @@ if (isCommonJS) exports.waits = waits;
* @param {String} optional_timeoutMessage
* @param {Number} optional_timeout
*/
-var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
+const waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
};
if (isCommonJS) exports.waitsFor = waitsFor;
@@ -567,7 +566,7 @@ if (isCommonJS) exports.waitsFor = waitsFor;
*
* @param {Function} beforeEachFunction
*/
-var beforeEach = function(beforeEachFunction) {
+const beforeEach = function(beforeEachFunction) {
jasmine.getEnv().beforeEach(beforeEachFunction);
};
if (isCommonJS) exports.beforeEach = beforeEach;
@@ -579,7 +578,7 @@ if (isCommonJS) exports.beforeEach = beforeEach;
*
* @param {Function} afterEachFunction
*/
-var afterEach = function(afterEachFunction) {
+const afterEach = function(afterEachFunction) {
jasmine.getEnv().afterEach(afterEachFunction);
};
if (isCommonJS) exports.afterEach = afterEach;
@@ -599,7 +598,7 @@ if (isCommonJS) exports.afterEach = afterEach;
* @param {String} description A string, usually the class under test.
* @param {Function} specDefinitions function that defines several specs.
*/
-var describe = function(description, specDefinitions) {
+const describe = function(description, specDefinitions) {
return jasmine.getEnv().describe(description, specDefinitions);
};
if (isCommonJS) exports.describe = describe;
@@ -610,36 +609,36 @@ if (isCommonJS) exports.describe = describe;
* @param {String} description A string, usually the class under test.
* @param {Function} specDefinitions function that defines several specs.
*/
-var xdescribe = function(description, specDefinitions) {
+const xdescribe = function(description, specDefinitions) {
return jasmine.getEnv().xdescribe(description, specDefinitions);
};
if (isCommonJS) exports.xdescribe = xdescribe;
// Provide the XMLHttpRequest class for IE 5.x-6.x:
-jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
+jasmine.XmlHttpRequest = (typeof XMLHttpRequest == 'undefined') ? function() {
function tryIt(f) {
try {
return f();
- } catch(e) {
+ } catch (e) {
}
return null;
}
- var xhr = tryIt(function() {
- return new ActiveXObject("Msxml2.XMLHTTP.6.0");
+ const xhr = tryIt(function() {
+ return new ActiveXObject('Msxml2.XMLHTTP.6.0');
}) ||
tryIt(function() {
- return new ActiveXObject("Msxml2.XMLHTTP.3.0");
+ return new ActiveXObject('Msxml2.XMLHTTP.3.0');
}) ||
tryIt(function() {
- return new ActiveXObject("Msxml2.XMLHTTP");
+ return new ActiveXObject('Msxml2.XMLHTTP');
}) ||
tryIt(function() {
- return new ActiveXObject("Microsoft.XMLHTTP");
+ return new ActiveXObject('Microsoft.XMLHTTP');
});
- if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
+ if (!xhr) throw new Error('This browser does not support XMLHttpRequest.');
return xhr;
} : XMLHttpRequest;
@@ -659,31 +658,29 @@ jasmine.util.inherit = function(childClass, parentClass) {
/**
* @private
*/
- var subclass = function() {
+ const subclass = function() {
};
subclass.prototype = parentClass.prototype;
childClass.prototype = new subclass();
};
jasmine.util.formatException = function(e) {
- var lineNumber;
+ let lineNumber;
if (e.line) {
lineNumber = e.line;
- }
- else if (e.lineNumber) {
+ } else if (e.lineNumber) {
lineNumber = e.lineNumber;
}
- var file;
+ let file;
if (e.sourceURL) {
file = e.sourceURL;
- }
- else if (e.fileName) {
+ } else if (e.fileName) {
file = e.fileName;
}
- var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
+ let message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
if (file && lineNumber) {
message += ' in ' + file + ' (line ' + lineNumber + ')';
@@ -695,18 +692,18 @@ jasmine.util.formatException = function(e) {
jasmine.util.htmlEscape = function(str) {
if (!str) return str;
return str.replace(/&/g, '&')
- .replace(//g, '>');
+ .replace(//g, '>');
};
jasmine.util.argsToArray = function(args) {
- var arrayOfArgs = [];
- for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
+ const arrayOfArgs = [];
+ for (let i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
return arrayOfArgs;
};
jasmine.util.extend = function(destination, source) {
- for (var property in source) destination[property] = source[property];
+ for (const property in source) destination[property] = source[property];
return destination;
};
@@ -749,9 +746,9 @@ jasmine.Env.prototype.setInterval = jasmine.setInterval;
jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
/**
- * @returns an object containing jasmine version build info, if set.
+ * @return an object containing jasmine version build info, if set.
*/
-jasmine.Env.prototype.version = function () {
+jasmine.Env.prototype.version = function() {
if (jasmine.version_) {
return jasmine.version_;
} else {
@@ -760,33 +757,33 @@ jasmine.Env.prototype.version = function () {
};
/**
- * @returns string containing jasmine version build info, if set.
+ * @return string containing jasmine version build info, if set.
*/
jasmine.Env.prototype.versionString = function() {
if (!jasmine.version_) {
- return "version unknown";
+ return 'version unknown';
}
- var version = this.version();
- var versionString = version.major + "." + version.minor + "." + version.build;
+ const version = this.version();
+ let versionString = version.major + '.' + version.minor + '.' + version.build;
if (version.release_candidate) {
- versionString += ".rc" + version.release_candidate;
+ versionString += '.rc' + version.release_candidate;
}
- versionString += " revision " + version.revision;
+ versionString += ' revision ' + version.revision;
return versionString;
};
/**
- * @returns a sequential integer starting at 0
+ * @return a sequential integer starting at 0
*/
-jasmine.Env.prototype.nextSpecId = function () {
+jasmine.Env.prototype.nextSpecId = function() {
return this.nextSpecId_++;
};
/**
- * @returns a sequential integer starting at 0
+ * @return a sequential integer starting at 0
*/
-jasmine.Env.prototype.nextSuiteId = function () {
+jasmine.Env.prototype.nextSuiteId = function() {
return this.nextSuiteId_++;
};
@@ -803,9 +800,9 @@ jasmine.Env.prototype.execute = function() {
};
jasmine.Env.prototype.describe = function(description, specDefinitions) {
- var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
+ const suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
- var parentSuite = this.currentSuite;
+ const parentSuite = this.currentSuite;
if (parentSuite) {
parentSuite.add(suite);
} else {
@@ -814,15 +811,15 @@ jasmine.Env.prototype.describe = function(description, specDefinitions) {
this.currentSuite = suite;
- var declarationError = null;
+ let declarationError = null;
try {
specDefinitions.call(suite);
- } catch(e) {
+ } catch (e) {
declarationError = e;
}
if (declarationError) {
- this.it("encountered a declaration exception", function() {
+ this.it('encountered a declaration exception', function() {
throw declarationError;
});
}
@@ -840,7 +837,7 @@ jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
}
};
-jasmine.Env.prototype.currentRunner = function () {
+jasmine.Env.prototype.currentRunner = function() {
return this.currentRunner_;
};
@@ -850,18 +847,17 @@ jasmine.Env.prototype.afterEach = function(afterEachFunction) {
} else {
this.currentRunner_.afterEach(afterEachFunction);
}
-
};
jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
return {
execute: function() {
- }
+ },
};
};
jasmine.Env.prototype.it = function(description, func) {
- var spec = new jasmine.Spec(this, this.currentSuite, description);
+ const spec = new jasmine.Spec(this, this.currentSuite, description);
this.currentSuite.add(spec);
this.currentSpec = spec;
@@ -876,25 +872,30 @@ jasmine.Env.prototype.xit = function(desc, func) {
return {
id: this.nextSpecId(),
runs: function() {
- }
+ },
};
};
jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) {
- if (a.source != b.source)
- mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/");
+ if (a.source != b.source) {
+ mismatchValues.push('expected pattern /' + b.source + '/ is not equal to the pattern /' + a.source + '/');
+ }
- if (a.ignoreCase != b.ignoreCase)
- mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier");
+ if (a.ignoreCase != b.ignoreCase) {
+ mismatchValues.push('expected modifier i was' + (b.ignoreCase ? ' ' : ' not ') + 'set and does not equal the origin modifier');
+ }
- if (a.global != b.global)
- mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier");
+ if (a.global != b.global) {
+ mismatchValues.push('expected modifier g was' + (b.global ? ' ' : ' not ') + 'set and does not equal the origin modifier');
+ }
- if (a.multiline != b.multiline)
- mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier");
+ if (a.multiline != b.multiline) {
+ mismatchValues.push('expected modifier m was' + (b.multiline ? ' ' : ' not ') + 'set and does not equal the origin modifier');
+ }
- if (a.sticky != b.sticky)
- mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier");
+ if (a.sticky != b.sticky) {
+ mismatchValues.push('expected modifier y was' + (b.sticky ? ' ' : ' not ') + 'set and does not equal the origin modifier');
+ }
return (mismatchValues.length === 0);
};
@@ -907,29 +908,29 @@ jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchVal
a.__Jasmine_been_here_before__ = b;
b.__Jasmine_been_here_before__ = a;
- var hasKey = function(obj, keyName) {
+ const hasKey = function(obj, keyName) {
return obj !== null && obj[keyName] !== jasmine.undefined;
};
for (var property in b) {
if (!hasKey(a, property) && hasKey(b, property)) {
- mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
+ mismatchKeys.push('expected has key \'' + property + '\', but missing from actual.');
}
}
for (property in a) {
if (!hasKey(b, property) && hasKey(a, property)) {
- mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
+ mismatchKeys.push('expected missing key \'' + property + '\', but present in actual.');
}
}
for (property in b) {
if (property == '__Jasmine_been_here_before__') continue;
if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {
- mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.");
+ mismatchValues.push('\'' + property + '\' was \'' + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + '\' in expected, but was \'' + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + '\' in actual.');
}
}
if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) {
- mismatchValues.push("arrays were not the same length");
+ mismatchValues.push('arrays were not the same length');
}
delete a.__Jasmine_been_here_before__;
@@ -941,9 +942,9 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
mismatchKeys = mismatchKeys || [];
mismatchValues = mismatchValues || [];
- for (var i = 0; i < this.equalityTesters_.length; i++) {
- var equalityTester = this.equalityTesters_[i];
- var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
+ for (let i = 0; i < this.equalityTesters_.length; i++) {
+ const equalityTester = this.equalityTesters_[i];
+ const result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
if (result !== jasmine.undefined) return result;
}
@@ -989,17 +990,17 @@ jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
return this.compareRegExps_(a, b, mismatchKeys, mismatchValues);
}
- if (typeof a === "object" && typeof b === "object") {
+ if (typeof a === 'object' && typeof b === 'object') {
return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
}
- //Straight check
+ // Straight check
return (a === b);
};
jasmine.Env.prototype.contains_ = function(haystack, needle) {
if (jasmine.isArray_(haystack)) {
- for (var i = 0; i < haystack.length; i++) {
+ for (let i = 0; i < haystack.length; i++) {
if (this.equals_(haystack[i], needle)) return true;
}
return false;
@@ -1017,27 +1018,27 @@ jasmine.Env.prototype.addEqualityTester = function(equalityTester) {
jasmine.Reporter = function() {
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.Reporter.prototype.reportRunnerStarting = function(runner) {
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.Reporter.prototype.reportSpecStarting = function(spec) {
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.Reporter.prototype.reportSpecResults = function(spec) {
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.Reporter.prototype.log = function(str) {
};
@@ -1058,8 +1059,7 @@ jasmine.Block = function(env, func, spec) {
jasmine.Block.prototype.execute = function(onComplete) {
if (!jasmine.CATCH_EXCEPTIONS) {
this.func.apply(this.spec);
- }
- else {
+ } else {
try {
this.func.apply(this.spec);
} catch (e) {
@@ -1081,9 +1081,9 @@ jasmine.JsApiReporter = function() {
jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
this.started = true;
- var suites = runner.topLevelSuites();
- for (var i = 0; i < suites.length; i++) {
- var suite = suites[i];
+ const suites = runner.topLevelSuites();
+ for (let i = 0; i < suites.length; i++) {
+ const suite = suites[i];
this.suites_.push(this.summarize_(suite));
}
};
@@ -1093,17 +1093,17 @@ jasmine.JsApiReporter.prototype.suites = function() {
};
jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
- var isSuite = suiteOrSpec instanceof jasmine.Suite;
- var summary = {
+ const isSuite = suiteOrSpec instanceof jasmine.Suite;
+ const summary = {
id: suiteOrSpec.id,
name: suiteOrSpec.description,
type: isSuite ? 'suite' : 'spec',
- children: []
+ children: [],
};
-
+
if (isSuite) {
- var children = suiteOrSpec.children();
- for (var i = 0; i < children.length; i++) {
+ const children = suiteOrSpec.children();
+ for (let i = 0; i < children.length; i++) {
summary.children.push(this.summarize_(children[i]));
}
}
@@ -1118,55 +1118,55 @@ jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) {
return this.results_[specId];
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) {
this.finished = true;
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) {
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
this.results_[spec.id] = {
messages: spec.results().getItems(),
- result: spec.results().failedCount > 0 ? "failed" : "passed"
+ result: spec.results().failedCount > 0 ? 'failed' : 'passed',
};
};
-//noinspection JSUnusedLocalSymbols
+// noinspection JSUnusedLocalSymbols
jasmine.JsApiReporter.prototype.log = function(str) {
};
-jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
- var results = {};
- for (var i = 0; i < specIds.length; i++) {
- var specId = specIds[i];
+jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds) {
+ const results = {};
+ for (let i = 0; i < specIds.length; i++) {
+ const specId = specIds[i];
results[specId] = this.summarizeResult_(this.results_[specId]);
}
return results;
};
-jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
- var summaryMessages = [];
- var messagesLength = result.messages.length;
- for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
- var resultMessage = result.messages[messageIndex];
+jasmine.JsApiReporter.prototype.summarizeResult_ = function(result) {
+ const summaryMessages = [];
+ const messagesLength = result.messages.length;
+ for (let messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
+ const resultMessage = result.messages[messageIndex];
summaryMessages.push({
text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined,
passed: resultMessage.passed ? resultMessage.passed() : true,
type: resultMessage.type,
message: resultMessage.message,
trace: {
- stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
- }
+ stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined,
+ },
});
}
return {
- result : result.result,
- messages : summaryMessages
+ result: result.result,
+ messages: summaryMessages,
};
};
@@ -1186,26 +1186,26 @@ jasmine.Matchers = function(env, actual, spec, opt_isNot) {
// todo: @deprecated as of Jasmine 0.11, remove soon [xw]
jasmine.Matchers.pp = function(str) {
- throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!");
+ throw new Error('jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!');
};
// todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw]
jasmine.Matchers.prototype.report = function(result, failing_message, details) {
- throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs");
+ throw new Error('As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs');
};
jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) {
- for (var methodName in prototype) {
+ for (const methodName in prototype) {
if (methodName == 'report') continue;
- var orig = prototype[methodName];
+ const orig = prototype[methodName];
matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
}
};
jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
return function() {
- var matcherArgs = jasmine.util.argsToArray(arguments);
- var result = matcherFunction.apply(this, arguments);
+ const matcherArgs = jasmine.util.argsToArray(arguments);
+ let result = matcherFunction.apply(this, arguments);
if (this.isNot) {
result = !result;
@@ -1213,7 +1213,7 @@ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
if (this.reportWasCalled_) return result;
- var message;
+ let message;
if (!result) {
if (this.message) {
message = this.message.apply(this, arguments);
@@ -1221,23 +1221,25 @@ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
message = message[this.isNot ? 1 : 0];
}
} else {
- var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
- message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate;
+ const englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) {
+ return ' ' + s.toLowerCase();
+ });
+ message = 'Expected ' + jasmine.pp(this.actual) + (this.isNot ? ' not ' : ' ') + englishyPredicate;
if (matcherArgs.length > 0) {
- for (var i = 0; i < matcherArgs.length; i++) {
- if (i > 0) message += ",";
- message += " " + jasmine.pp(matcherArgs[i]);
+ for (let i = 0; i < matcherArgs.length; i++) {
+ if (i > 0) message += ',';
+ message += ' ' + jasmine.pp(matcherArgs[i]);
}
}
- message += ".";
+ message += '.';
}
}
- var expectationResult = new jasmine.ExpectationResult({
+ const expectationResult = new jasmine.ExpectationResult({
matcherName: matcherName,
passed: result,
expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],
actual: this.actual,
- message: message
+ message: message,
});
this.spec.addMatcherResult(expectationResult);
return jasmine.undefined;
@@ -1245,8 +1247,6 @@ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
};
-
-
/**
* toBe: compares the actual to the expected using ===
* @param expected
@@ -1326,11 +1326,11 @@ jasmine.Matchers.prototype.toBeNull = function() {
* Matcher that compares the actual to NaN.
*/
jasmine.Matchers.prototype.toBeNaN = function() {
- this.message = function() {
- return [ "Expected " + jasmine.pp(this.actual) + " to be NaN." ];
- };
+ this.message = function() {
+ return ['Expected ' + jasmine.pp(this.actual) + ' to be NaN.'];
+ };
- return (this.actual !== this.actual);
+ return (this.actual !== this.actual);
};
/**
@@ -1363,8 +1363,8 @@ jasmine.Matchers.prototype.toHaveBeenCalled = function() {
this.message = function() {
return [
- "Expected spy " + this.actual.identity + " to have been called.",
- "Expected spy " + this.actual.identity + " not to have been called."
+ 'Expected spy ' + this.actual.identity + ' to have been called.',
+ 'Expected spy ' + this.actual.identity + ' not to have been called.',
];
};
@@ -1390,8 +1390,8 @@ jasmine.Matchers.prototype.wasNotCalled = function() {
this.message = function() {
return [
- "Expected spy " + this.actual.identity + " to not have been called.",
- "Expected spy " + this.actual.identity + " to have been called."
+ 'Expected spy ' + this.actual.identity + ' to not have been called.',
+ 'Expected spy ' + this.actual.identity + ' to have been called.',
];
};
@@ -1405,17 +1405,17 @@ jasmine.Matchers.prototype.wasNotCalled = function() {
*
*/
jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
- var expectedArgs = jasmine.util.argsToArray(arguments);
+ const expectedArgs = jasmine.util.argsToArray(arguments);
if (!jasmine.isSpy(this.actual)) {
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
}
this.message = function() {
- var invertedMessage = "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was.";
- var positiveMessage = "";
+ const invertedMessage = 'Expected spy ' + this.actual.identity + ' not to have been called with ' + jasmine.pp(expectedArgs) + ' but it was.';
+ let positiveMessage = '';
if (this.actual.callCount === 0) {
- positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";
+ positiveMessage = 'Expected spy ' + this.actual.identity + ' to have been called with ' + jasmine.pp(expectedArgs) + ' but it was never called.';
} else {
- positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but actual calls were " + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '')
+ positiveMessage = 'Expected spy ' + this.actual.identity + ' to have been called with ' + jasmine.pp(expectedArgs) + ' but actual calls were ' + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '');
}
return [positiveMessage, invertedMessage];
};
@@ -1428,15 +1428,15 @@ jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.prototype.toHaveBeen
/** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */
jasmine.Matchers.prototype.wasNotCalledWith = function() {
- var expectedArgs = jasmine.util.argsToArray(arguments);
+ const expectedArgs = jasmine.util.argsToArray(arguments);
if (!jasmine.isSpy(this.actual)) {
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
}
this.message = function() {
return [
- "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
- "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
+ 'Expected spy not to have been called with ' + jasmine.pp(expectedArgs) + ' but it was',
+ 'Expected spy to have been called with ' + jasmine.pp(expectedArgs) + ' but it was',
];
};
@@ -1490,8 +1490,8 @@ jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
* @param {String} [expected]
*/
jasmine.Matchers.prototype.toThrow = function(expected) {
- var result = false;
- var exception;
+ let result = false;
+ let exception;
if (typeof this.actual != 'function') {
throw new Error('Actual is not a function');
}
@@ -1504,13 +1504,13 @@ jasmine.Matchers.prototype.toThrow = function(expected) {
result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
}
- var not = this.isNot ? "not " : "";
+ const not = this.isNot ? 'not ' : '';
this.message = function() {
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
- return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
+ return ['Expected function ' + not + 'to throw', expected ? expected.message || expected : 'an exception', ', but it threw', exception.message || exception].join(' ');
} else {
- return "Expected function to throw an exception.";
+ return 'Expected function to throw an exception.';
}
};
@@ -1545,7 +1545,7 @@ jasmine.Matchers.Any.prototype.jasmineToString = function() {
return '%s
%e', str)); @@ -160,12 +160,12 @@ function HTML(runner, root) { // toggle code // TODO: defer if (!test.pending) { - var h2 = el.getElementsByTagName('h2')[0]; + const h2 = el.getElementsByTagName('h2')[0]; - on(h2, 'click', function(){ - pre.style.display = 'none' == pre.style.display - ? 'block' - : 'none'; + on(h2, 'click', function() { + pre.style.display = 'none' == pre.style.display ? + 'block' : + 'none'; }); var pre = fragment('
%e
', utils.clean(test.fn.toString()));
@@ -184,7 +184,7 @@ function HTML(runner, root) {
* @param {Object} [suite]
*/
-HTML.prototype.suiteURL = function(suite){
+HTML.prototype.suiteURL = function(suite) {
return '?grep=' + encodeURIComponent(suite.fullTitle());
};
@@ -194,7 +194,7 @@ HTML.prototype.suiteURL = function(suite){
* @param {Object} [test]
*/
-HTML.prototype.testURL = function(test){
+HTML.prototype.testURL = function(test) {
return '?grep=' + encodeURIComponent(test.fullTitle());
};
@@ -211,11 +211,11 @@ function error(msg) {
*/
function fragment(html) {
- var args = arguments
- , div = document.createElement('div')
- , i = 1;
+ const args = arguments
+ ; const div = document.createElement('div')
+ ; let i = 1;
- div.innerHTML = html.replace(/%([se])/g, function(_, type){
+ div.innerHTML = html.replace(/%([se])/g, function(_, type) {
switch (type) {
case 's': return String(args[i++]);
case 'e': return escape(args[i++]);
@@ -231,9 +231,9 @@ function fragment(html) {
*/
function hideSuitesWithout(classname) {
- var suites = document.getElementsByClassName('suite');
- for (var i = 0; i < suites.length; i++) {
- var els = suites[i].getElementsByClassName(classname);
+ const suites = document.getElementsByClassName('suite');
+ for (let i = 0; i < suites.length; i++) {
+ const els = suites[i].getElementsByClassName(classname);
if (0 == els.length) suites[i].className += ' hidden';
}
}
@@ -243,8 +243,8 @@ function hideSuitesWithout(classname) {
*/
function unhide() {
- var els = document.getElementsByClassName('suite hidden');
- for (var i = 0; i < els.length; ++i) {
+ const els = document.getElementsByClassName('suite hidden');
+ for (let i = 0; i < els.length; ++i) {
els[i].className = els[i].className.replace('suite hidden', 'suite');
}
}
diff --git a/test/mocha/lib/reporters/json-cov.js b/test/mocha/lib/reporters/json-cov.js
index 73d0009..4c88df7 100644
--- a/test/mocha/lib/reporters/json-cov.js
+++ b/test/mocha/lib/reporters/json-cov.js
@@ -3,7 +3,7 @@
* Module dependencies.
*/
-var Base = require('./base');
+const Base = require('./base');
/**
* Expose `JSONCov`.
@@ -20,30 +20,30 @@ exports = module.exports = JSONCov;
*/
function JSONCov(runner, output) {
- var self = this
- , output = 1 == arguments.length ? true : output;
+ const self = this
+ ; var output = 1 == arguments.length ? true : output;
Base.call(this, runner);
- var tests = []
- , failures = []
- , passes = [];
+ const tests = []
+ ; const failures = []
+ ; const passes = [];
- runner.on('test end', function(test){
+ runner.on('test end', function(test) {
tests.push(test);
});
- runner.on('pass', function(test){
+ runner.on('pass', function(test) {
passes.push(test);
});
- runner.on('fail', function(test){
+ runner.on('fail', function(test) {
failures.push(test);
});
- runner.on('end', function(){
- var cov = global._$jscoverage || {};
- var result = self.cov = map(cov);
+ runner.on('end', function() {
+ const cov = global._$jscoverage || {};
+ const result = self.cov = map(cov);
result.stats = self.stats;
result.tests = tests.map(clean);
result.failures = failures.map(clean);
@@ -63,17 +63,17 @@ function JSONCov(runner, output) {
*/
function map(cov) {
- var ret = {
- instrumentation: 'node-jscoverage'
- , sloc: 0
- , hits: 0
- , misses: 0
- , coverage: 0
- , files: []
+ const ret = {
+ instrumentation: 'node-jscoverage',
+ sloc: 0,
+ hits: 0,
+ misses: 0,
+ coverage: 0,
+ files: [],
};
- for (var filename in cov) {
- var data = coverage(filename, cov[filename]);
+ for (const filename in cov) {
+ const data = coverage(filename, cov[filename]);
ret.files.push(data);
ret.hits += data.hits;
ret.misses += data.misses;
@@ -102,16 +102,16 @@ function map(cov) {
*/
function coverage(filename, data) {
- var ret = {
+ const ret = {
filename: filename,
coverage: 0,
hits: 0,
misses: 0,
sloc: 0,
- source: {}
+ source: {},
};
- data.source.forEach(function(line, num){
+ data.source.forEach(function(line, num) {
num++;
if (data[num] === 0) {
@@ -123,10 +123,10 @@ function coverage(filename, data) {
}
ret.source[num] = {
- source: line
- , coverage: data[num] === undefined
- ? ''
- : data[num]
+ source: line,
+ coverage: data[num] === undefined ?
+ '' :
+ data[num],
};
});
@@ -146,8 +146,8 @@ function coverage(filename, data) {
function clean(test) {
return {
- title: test.title
- , fullTitle: test.fullTitle()
- , duration: test.duration
- }
+ title: test.title,
+ fullTitle: test.fullTitle(),
+ duration: test.duration,
+ };
}
diff --git a/test/mocha/lib/reporters/json-stream.js b/test/mocha/lib/reporters/json-stream.js
index 7cb8fbe..0d5dffc 100644
--- a/test/mocha/lib/reporters/json-stream.js
+++ b/test/mocha/lib/reporters/json-stream.js
@@ -3,8 +3,8 @@
* Module dependencies.
*/
-var Base = require('./base')
- , color = Base.color;
+const Base = require('./base')
+ ; const color = Base.color;
/**
* Expose `List`.
@@ -22,23 +22,23 @@ exports = module.exports = List;
function List(runner) {
Base.call(this, runner);
- var self = this
- , stats = this.stats
- , total = runner.total;
+ const self = this
+ ; const stats = this.stats
+ ; const total = runner.total;
- runner.on('start', function(){
- console.log(JSON.stringify(['start', { total: total }]));
+ runner.on('start', function() {
+ console.log(JSON.stringify(['start', {total: total}]));
});
- runner.on('pass', function(test){
+ runner.on('pass', function(test) {
console.log(JSON.stringify(['pass', clean(test)]));
});
- runner.on('fail', function(test, err){
+ runner.on('fail', function(test, err) {
console.log(JSON.stringify(['fail', clean(test)]));
});
- runner.on('end', function(){
+ runner.on('end', function() {
process.stdout.write(JSON.stringify(['end', self.stats]));
});
}
@@ -54,8 +54,8 @@ function List(runner) {
function clean(test) {
return {
- title: test.title
- , fullTitle: test.fullTitle()
- , duration: test.duration
- }
-}
\ No newline at end of file
+ title: test.title,
+ fullTitle: test.fullTitle(),
+ duration: test.duration,
+ };
+}
diff --git a/test/mocha/lib/reporters/json.js b/test/mocha/lib/reporters/json.js
index a699f50..7df0557 100644
--- a/test/mocha/lib/reporters/json.js
+++ b/test/mocha/lib/reporters/json.js
@@ -3,9 +3,9 @@
* Module dependencies.
*/
-var Base = require('./base')
- , cursor = Base.cursor
- , color = Base.color;
+const Base = require('./base')
+ ; const cursor = Base.cursor
+ ; const color = Base.color;
/**
* Expose `JSON`.
@@ -21,31 +21,31 @@ exports = module.exports = JSONReporter;
*/
function JSONReporter(runner) {
- var self = this;
+ const self = this;
Base.call(this, runner);
- var tests = []
- , failures = []
- , passes = [];
+ const tests = []
+ ; const failures = []
+ ; const passes = [];
- runner.on('test end', function(test){
+ runner.on('test end', function(test) {
tests.push(test);
});
- runner.on('pass', function(test){
+ runner.on('pass', function(test) {
passes.push(test);
});
- runner.on('fail', function(test){
+ runner.on('fail', function(test) {
failures.push(test);
});
- runner.on('end', function(){
- var obj = {
- stats: self.stats
- , tests: tests.map(clean)
- , failures: failures.map(clean)
- , passes: passes.map(clean)
+ runner.on('end', function() {
+ const obj = {
+ stats: self.stats,
+ tests: tests.map(clean),
+ failures: failures.map(clean),
+ passes: passes.map(clean),
};
process.stdout.write(JSON.stringify(obj, null, 2));
@@ -63,8 +63,8 @@ function JSONReporter(runner) {
function clean(test) {
return {
- title: test.title
- , fullTitle: test.fullTitle()
- , duration: test.duration
- }
-}
\ No newline at end of file
+ title: test.title,
+ fullTitle: test.fullTitle(),
+ duration: test.duration,
+ };
+}
diff --git a/test/mocha/lib/reporters/landing.js b/test/mocha/lib/reporters/landing.js
index bf064f6..91b431d 100644
--- a/test/mocha/lib/reporters/landing.js
+++ b/test/mocha/lib/reporters/landing.js
@@ -3,9 +3,9 @@
* Module dependencies.
*/
-var Base = require('./base')
- , cursor = Base.cursor
- , color = Base.color;
+const Base = require('./base')
+ ; const cursor = Base.cursor
+ ; const color = Base.color;
/**
* Expose `Landing`.
@@ -41,30 +41,30 @@ Base.colors.runway = 90;
function Landing(runner) {
Base.call(this, runner);
- var self = this
- , stats = this.stats
- , width = Base.window.width * .75 | 0
- , total = runner.total
- , stream = process.stdout
- , plane = color('plane', '✈')
- , crashed = -1
- , n = 0;
+ const self = this
+ ; const stats = this.stats
+ ; const width = Base.window.width * .75 | 0
+ ; const total = runner.total
+ ; const stream = process.stdout
+ ; let plane = color('plane', '✈')
+ ; let crashed = -1
+ ; let n = 0;
function runway() {
- var buf = Array(width).join('-');
+ const buf = Array(width).join('-');
return ' ' + color('runway', buf);
}
- runner.on('start', function(){
+ runner.on('start', function() {
stream.write('\n ');
cursor.hide();
});
- runner.on('test end', function(test){
+ runner.on('test end', function(test) {
// check if the plane crashed
- var col = -1 == crashed
- ? width * ++n / total | 0
- : crashed;
+ const col = -1 == crashed ?
+ width * ++n / total | 0 :
+ crashed;
// show the crash
if ('failed' == test.state) {
@@ -77,13 +77,13 @@ function Landing(runner) {
stream.write(runway());
stream.write('\n ');
stream.write(color('runway', Array(col).join('⋅')));
- stream.write(plane)
+ stream.write(plane);
stream.write(color('runway', Array(width - col).join('⋅') + '\n'));
stream.write(runway());
stream.write('\u001b[0m');
});
- runner.on('end', function(){
+ runner.on('end', function() {
cursor.show();
console.log();
self.epilogue();
@@ -94,4 +94,4 @@ function Landing(runner) {
* Inherit from `Base.prototype`.
*/
-Landing.prototype.__proto__ = Base.prototype;
\ No newline at end of file
+Landing.prototype.__proto__ = Base.prototype;
diff --git a/test/mocha/lib/reporters/list.js b/test/mocha/lib/reporters/list.js
index 3328e15..9221cf6 100644
--- a/test/mocha/lib/reporters/list.js
+++ b/test/mocha/lib/reporters/list.js
@@ -3,9 +3,9 @@
* Module dependencies.
*/
-var Base = require('./base')
- , cursor = Base.cursor
- , color = Base.color;
+const Base = require('./base')
+ ; const cursor = Base.cursor
+ ; const color = Base.color;
/**
* Expose `List`.
@@ -23,33 +23,33 @@ exports = module.exports = List;
function List(runner) {
Base.call(this, runner);
- var self = this
- , stats = this.stats
- , n = 0;
+ const self = this
+ ; const stats = this.stats
+ ; let n = 0;
- runner.on('start', function(){
+ runner.on('start', function() {
console.log();
});
- runner.on('test', function(test){
+ runner.on('test', function(test) {
process.stdout.write(color('pass', ' ' + test.fullTitle() + ': '));
});
- runner.on('pending', function(test){
- var fmt = color('checkmark', ' -')
- + color('pending', ' %s');
+ runner.on('pending', function(test) {
+ const fmt = color('checkmark', ' -') +
+ color('pending', ' %s');
console.log(fmt, test.fullTitle());
});
- runner.on('pass', function(test){
- var fmt = color('checkmark', ' '+Base.symbols.dot)
- + color('pass', ' %s: ')
- + color(test.speed, '%dms');
+ runner.on('pass', function(test) {
+ const fmt = color('checkmark', ' '+Base.symbols.dot) +
+ color('pass', ' %s: ') +
+ color(test.speed, '%dms');
cursor.CR();
console.log(fmt, test.fullTitle(), test.duration);
});
- runner.on('fail', function(test, err){
+ runner.on('fail', function(test, err) {
cursor.CR();
console.log(color('fail', ' %d) %s'), ++n, test.fullTitle());
});
diff --git a/test/mocha/lib/reporters/markdown.js b/test/mocha/lib/reporters/markdown.js
index 6383a64..9a8b5c1 100644
--- a/test/mocha/lib/reporters/markdown.js
+++ b/test/mocha/lib/reporters/markdown.js
@@ -2,8 +2,8 @@
* Module dependencies.
*/
-var Base = require('./base')
- , utils = require('../utils');
+const Base = require('./base')
+ ; const utils = require('../utils');
/**
* Expose `Markdown`.
@@ -21,10 +21,10 @@ exports = module.exports = Markdown;
function Markdown(runner) {
Base.call(this, runner);
- var self = this
- , stats = this.stats
- , level = 0
- , buf = '';
+ const self = this
+ ; const stats = this.stats
+ ; let level = 0
+ ; let buf = '';
function title(str) {
return Array(level).join('#') + ' ' + str;
@@ -35,9 +35,9 @@ function Markdown(runner) {
}
function mapTOC(suite, obj) {
- var ret = obj;
- obj = obj[suite.title] = obj[suite.title] || { suite: suite };
- suite.suites.forEach(function(suite){
+ const ret = obj;
+ obj = obj[suite.title] = obj[suite.title] || {suite: suite};
+ suite.suites.forEach(function(suite) {
mapTOC(suite, obj);
});
return ret;
@@ -45,9 +45,9 @@ function Markdown(runner) {
function stringifyTOC(obj, level) {
++level;
- var buf = '';
- var link;
- for (var key in obj) {
+ let buf = '';
+ let link;
+ for (const key in obj) {
if ('suite' == key) continue;
if (key) link = ' - [' + key + '](#' + utils.slug(obj[key].suite.fullTitle()) + ')\n';
if (key) buf += Array(level).join(' ') + link;
@@ -58,34 +58,34 @@ function Markdown(runner) {
}
function generateTOC(suite) {
- var obj = mapTOC(suite, {});
+ const obj = mapTOC(suite, {});
return stringifyTOC(obj, 0);
}
generateTOC(runner.suite);
- runner.on('suite', function(suite){
+ runner.on('suite', function(suite) {
++level;
- var slug = utils.slug(suite.fullTitle());
+ const slug = utils.slug(suite.fullTitle());
buf += '' + '\n';
buf += title(suite.title) + '\n';
});
- runner.on('suite end', function(suite){
+ runner.on('suite end', function(suite) {
--level;
});
- runner.on('pass', function(test){
- var code = utils.clean(test.fn.toString());
+ runner.on('pass', function(test) {
+ const code = utils.clean(test.fn.toString());
buf += test.title + '.\n';
buf += '\n```js\n';
buf += code + '\n';
buf += '```\n\n';
});
- runner.on('end', function(){
+ runner.on('end', function() {
process.stdout.write('# TOC\n');
process.stdout.write(generateTOC(runner.suite));
process.stdout.write(buf);
});
-}
\ No newline at end of file
+}
diff --git a/test/mocha/lib/reporters/min.js b/test/mocha/lib/reporters/min.js
index 1b6117d..cc84680 100644
--- a/test/mocha/lib/reporters/min.js
+++ b/test/mocha/lib/reporters/min.js
@@ -3,7 +3,7 @@
* Module dependencies.
*/
-var Base = require('./base');
+const Base = require('./base');
/**
* Expose `Min`.
@@ -21,7 +21,7 @@ exports = module.exports = Min;
function Min(runner) {
Base.call(this, runner);
- runner.on('start', function(){
+ runner.on('start', function() {
// clear screen
process.stdout.write('\u001b[2J');
// set cursor position
diff --git a/test/mocha/lib/reporters/nyan.js b/test/mocha/lib/reporters/nyan.js
index 4501f6b..e32f4e9 100644
--- a/test/mocha/lib/reporters/nyan.js
+++ b/test/mocha/lib/reporters/nyan.js
@@ -2,8 +2,8 @@
* Module dependencies.
*/
-var Base = require('./base')
- , color = Base.color;
+const Base = require('./base')
+ ; const color = Base.color;
/**
* Expose `Dot`.
@@ -20,39 +20,39 @@ exports = module.exports = NyanCat;
function NyanCat(runner) {
Base.call(this, runner);
- var self = this
- , stats = this.stats
- , width = Base.window.width * .75 | 0
- , rainbowColors = this.rainbowColors = self.generateColors()
- , colorIndex = this.colorIndex = 0
- , numerOfLines = this.numberOfLines = 4
- , trajectories = this.trajectories = [[], [], [], []]
- , nyanCatWidth = this.nyanCatWidth = 11
- , trajectoryWidthMax = this.trajectoryWidthMax = (width - nyanCatWidth)
- , scoreboardWidth = this.scoreboardWidth = 5
- , tick = this.tick = 0
- , n = 0;
-
- runner.on('start', function(){
+ const self = this
+ ; const stats = this.stats
+ ; const width = Base.window.width * .75 | 0
+ ; const rainbowColors = this.rainbowColors = self.generateColors()
+ ; const colorIndex = this.colorIndex = 0
+ ; const numerOfLines = this.numberOfLines = 4
+ ; const trajectories = this.trajectories = [[], [], [], []]
+ ; const nyanCatWidth = this.nyanCatWidth = 11
+ ; const trajectoryWidthMax = this.trajectoryWidthMax = (width - nyanCatWidth)
+ ; const scoreboardWidth = this.scoreboardWidth = 5
+ ; const tick = this.tick = 0
+ ; const n = 0;
+
+ runner.on('start', function() {
Base.cursor.hide();
self.draw();
});
- runner.on('pending', function(test){
+ runner.on('pending', function(test) {
self.draw();
});
- runner.on('pass', function(test){
+ runner.on('pass', function(test) {
self.draw();
});
- runner.on('fail', function(test, err){
+ runner.on('fail', function(test, err) {
self.draw();
});
- runner.on('end', function(){
+ runner.on('end', function() {
Base.cursor.show();
- for (var i = 0; i < self.numberOfLines; i++) write('\n');
+ for (let i = 0; i < self.numberOfLines; i++) write('\n');
self.epilogue();
});
}
@@ -63,7 +63,7 @@ function NyanCat(runner) {
* @api private
*/
-NyanCat.prototype.draw = function(){
+NyanCat.prototype.draw = function() {
this.appendRainbow();
this.drawScoreboard();
this.drawRainbow();
@@ -78,9 +78,9 @@ NyanCat.prototype.draw = function(){
* @api private
*/
-NyanCat.prototype.drawScoreboard = function(){
- var stats = this.stats;
- var colors = Base.colors;
+NyanCat.prototype.drawScoreboard = function() {
+ const stats = this.stats;
+ const colors = Base.colors;
function draw(color, n) {
write(' ');
@@ -102,12 +102,12 @@ NyanCat.prototype.drawScoreboard = function(){
* @api private
*/
-NyanCat.prototype.appendRainbow = function(){
- var segment = this.tick ? '_' : '-';
- var rainbowified = this.rainbowify(segment);
+NyanCat.prototype.appendRainbow = function() {
+ const segment = this.tick ? '_' : '-';
+ const rainbowified = this.rainbowify(segment);
- for (var index = 0; index < this.numberOfLines; index++) {
- var trajectory = this.trajectories[index];
+ for (let index = 0; index < this.numberOfLines; index++) {
+ const trajectory = this.trajectories[index];
if (trajectory.length >= this.trajectoryWidthMax) trajectory.shift();
trajectory.push(rainbowified);
}
@@ -119,8 +119,8 @@ NyanCat.prototype.appendRainbow = function(){
* @api private
*/
-NyanCat.prototype.drawRainbow = function(){
- var self = this;
+NyanCat.prototype.drawRainbow = function() {
+ const self = this;
this.trajectories.forEach(function(line, index) {
write('\u001b[' + self.scoreboardWidth + 'C');
@@ -138,10 +138,10 @@ NyanCat.prototype.drawRainbow = function(){
*/
NyanCat.prototype.drawNyanCat = function() {
- var self = this;
- var startWidth = this.scoreboardWidth + this.trajectories[0].length;
- var color = '\u001b[' + startWidth + 'C';
- var padding = '';
+ const self = this;
+ const startWidth = this.scoreboardWidth + this.trajectories[0].length;
+ const color = '\u001b[' + startWidth + 'C';
+ let padding = '';
write(color);
write('_,------,');
@@ -154,8 +154,8 @@ NyanCat.prototype.drawNyanCat = function() {
write(color);
padding = self.tick ? '_' : '__';
- var tail = self.tick ? '~' : '^';
- var face;
+ const tail = self.tick ? '~' : '^';
+ let face;
write(tail + '|' + padding + this.face() + ' ');
write('\n');
@@ -175,17 +175,17 @@ NyanCat.prototype.drawNyanCat = function() {
*/
NyanCat.prototype.face = function() {
- var stats = this.stats;
+ const stats = this.stats;
if (stats.failures) {
return '( x .x)';
} else if (stats.pending) {
return '( o .o)';
- } else if(stats.passes) {
+ } else if (stats.passes) {
return '( ^ .^)';
} else {
return '( - .-)';
}
-}
+};
/**
* Move cursor up `n`.
@@ -216,15 +216,15 @@ NyanCat.prototype.cursorDown = function(n) {
* @api private
*/
-NyanCat.prototype.generateColors = function(){
- var colors = [];
+NyanCat.prototype.generateColors = function() {
+ const colors = [];
- for (var i = 0; i < (6 * 7); i++) {
- var pi3 = Math.floor(Math.PI / 3);
- var n = (i * (1.0 / 6));
- var r = Math.floor(3 * Math.sin(n) + 3);
- var g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
- var b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
+ for (let i = 0; i < (6 * 7); i++) {
+ const pi3 = Math.floor(Math.PI / 3);
+ const n = (i * (1.0 / 6));
+ const r = Math.floor(3 * Math.sin(n) + 3);
+ const g = Math.floor(3 * Math.sin(n + 2 * pi3) + 3);
+ const b = Math.floor(3 * Math.sin(n + 4 * pi3) + 3);
colors.push(36 * r + 6 * g + b + 16);
}
@@ -239,8 +239,8 @@ NyanCat.prototype.generateColors = function(){
* @api private
*/
-NyanCat.prototype.rainbowify = function(str){
- var color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
+NyanCat.prototype.rainbowify = function(str) {
+ const color = this.rainbowColors[this.colorIndex % this.rainbowColors.length];
this.colorIndex += 1;
return '\u001b[38;5;' + color + 'm' + str + '\u001b[0m';
};
diff --git a/test/mocha/lib/reporters/progress.js b/test/mocha/lib/reporters/progress.js
index 5953638..c6ae406 100644
--- a/test/mocha/lib/reporters/progress.js
+++ b/test/mocha/lib/reporters/progress.js
@@ -3,9 +3,9 @@
* Module dependencies.
*/
-var Base = require('./base')
- , cursor = Base.cursor
- , color = Base.color;
+const Base = require('./base')
+ ; const cursor = Base.cursor
+ ; const color = Base.color;
/**
* Expose `Progress`.
@@ -30,13 +30,13 @@ Base.colors.progress = 90;
function Progress(runner, options) {
Base.call(this, runner);
- var self = this
- , options = options || {}
- , stats = this.stats
- , width = Base.window.width * .50 | 0
- , total = runner.total
- , complete = 0
- , max = Math.max;
+ const self = this
+ ; var options = options || {}
+ ; const stats = this.stats
+ ; const width = Base.window.width * .50 | 0
+ ; const total = runner.total
+ ; let complete = 0
+ ; const max = Math.max;
// default chars
options.open = options.open || '[';
@@ -46,18 +46,18 @@ function Progress(runner, options) {
options.verbose = false;
// tests started
- runner.on('start', function(){
+ runner.on('start', function() {
console.log();
cursor.hide();
});
// tests complete
- runner.on('test end', function(){
+ runner.on('test end', function() {
complete++;
- var incomplete = total - complete
- , percent = complete / total
- , n = width * percent | 0
- , i = width - n;
+ const incomplete = total - complete
+ ; const percent = complete / total
+ ; const n = width * percent | 0
+ ; const i = width - n;
cursor.CR();
process.stdout.write('\u001b[J');
@@ -72,7 +72,7 @@ function Progress(runner, options) {
// tests are complete, output some stats
// and the failures if any
- runner.on('end', function(){
+ runner.on('end', function() {
cursor.show();
console.log();
self.epilogue();
diff --git a/test/mocha/lib/reporters/spec.js b/test/mocha/lib/reporters/spec.js
index ada25c3..fa22a00 100644
--- a/test/mocha/lib/reporters/spec.js
+++ b/test/mocha/lib/reporters/spec.js
@@ -3,9 +3,9 @@
* Module dependencies.
*/
-var Base = require('./base')
- , cursor = Base.cursor
- , color = Base.color;
+const Base = require('./base')
+ ; const cursor = Base.cursor
+ ; const color = Base.color;
/**
* Expose `Spec`.
@@ -23,52 +23,52 @@ exports = module.exports = Spec;
function Spec(runner) {
Base.call(this, runner);
- var self = this
- , stats = this.stats
- , indents = 0
- , n = 0;
+ const self = this
+ ; const stats = this.stats
+ ; let indents = 0
+ ; let n = 0;
function indent() {
- return Array(indents).join(' ')
+ return Array(indents).join(' ');
}
- runner.on('start', function(){
+ runner.on('start', function() {
console.log();
});
- runner.on('suite', function(suite){
+ runner.on('suite', function(suite) {
++indents;
console.log(color('suite', '%s%s'), indent(), suite.title);
});
- runner.on('suite end', function(suite){
+ runner.on('suite end', function(suite) {
--indents;
if (1 == indents) console.log();
});
- runner.on('pending', function(test){
- var fmt = indent() + color('pending', ' - %s');
+ runner.on('pending', function(test) {
+ const fmt = indent() + color('pending', ' - %s');
console.log(fmt, test.title);
});
- runner.on('pass', function(test){
+ runner.on('pass', function(test) {
if ('fast' == test.speed) {
- var fmt = indent()
- + color('checkmark', ' ' + Base.symbols.ok)
- + color('pass', ' %s ');
+ var fmt = indent() +
+ color('checkmark', ' ' + Base.symbols.ok) +
+ color('pass', ' %s ');
cursor.CR();
console.log(fmt, test.title);
} else {
- var fmt = indent()
- + color('checkmark', ' ' + Base.symbols.ok)
- + color('pass', ' %s ')
- + color(test.speed, '(%dms)');
+ var fmt = indent() +
+ color('checkmark', ' ' + Base.symbols.ok) +
+ color('pass', ' %s ') +
+ color(test.speed, '(%dms)');
cursor.CR();
console.log(fmt, test.title, test.duration);
}
});
- runner.on('fail', function(test, err){
+ runner.on('fail', function(test, err) {
cursor.CR();
console.log(indent() + color('fail', ' %d) %s'), ++n, test.title);
});
diff --git a/test/mocha/lib/reporters/tap.js b/test/mocha/lib/reporters/tap.js
index 2bcd995..10a668f 100644
--- a/test/mocha/lib/reporters/tap.js
+++ b/test/mocha/lib/reporters/tap.js
@@ -3,9 +3,9 @@
* Module dependencies.
*/
-var Base = require('./base')
- , cursor = Base.cursor
- , color = Base.color;
+const Base = require('./base')
+ ; const cursor = Base.cursor
+ ; const color = Base.color;
/**
* Expose `TAP`.
@@ -23,37 +23,37 @@ exports = module.exports = TAP;
function TAP(runner) {
Base.call(this, runner);
- var self = this
- , stats = this.stats
- , n = 1
- , passes = 0
- , failures = 0;
+ const self = this
+ ; const stats = this.stats
+ ; let n = 1
+ ; let passes = 0
+ ; let failures = 0;
- runner.on('start', function(){
- var total = runner.grepTotal(runner.suite);
+ runner.on('start', function() {
+ const total = runner.grepTotal(runner.suite);
console.log('%d..%d', 1, total);
});
- runner.on('test end', function(){
+ runner.on('test end', function() {
++n;
});
- runner.on('pending', function(test){
+ runner.on('pending', function(test) {
console.log('ok %d %s # SKIP -', n, title(test));
});
- runner.on('pass', function(test){
+ runner.on('pass', function(test) {
passes++;
console.log('ok %d %s', n, title(test));
});
- runner.on('fail', function(test, err){
+ runner.on('fail', function(test, err) {
failures++;
console.log('not ok %d %s', n, title(test));
if (err.stack) console.log(err.stack.replace(/^/gm, ' '));
});
- runner.on('end', function(){
+ runner.on('end', function() {
console.log('# tests ' + (passes + failures));
console.log('# pass ' + passes);
console.log('# fail ' + failures);
diff --git a/test/mocha/lib/reporters/xunit.js b/test/mocha/lib/reporters/xunit.js
index e956380..6a40ed9 100644
--- a/test/mocha/lib/reporters/xunit.js
+++ b/test/mocha/lib/reporters/xunit.js
@@ -3,19 +3,19 @@
* Module dependencies.
*/
-var Base = require('./base')
- , utils = require('../utils')
- , escape = utils.escape;
+const Base = require('./base')
+ ; const utils = require('../utils')
+ ; const escape = utils.escape;
/**
* Save timer references to avoid Sinon interfering (see GH-237).
*/
-var Date = global.Date
- , setTimeout = global.setTimeout
- , setInterval = global.setInterval
- , clearTimeout = global.clearTimeout
- , clearInterval = global.clearInterval;
+const Date = global.Date
+ ; const setTimeout = global.setTimeout
+ ; const setInterval = global.setInterval
+ ; const clearTimeout = global.clearTimeout
+ ; const clearInterval = global.clearInterval;
/**
* Expose `XUnit`.
@@ -32,31 +32,31 @@ exports = module.exports = XUnit;
function XUnit(runner) {
Base.call(this, runner);
- var stats = this.stats
- , tests = []
- , self = this;
+ const stats = this.stats
+ ; const tests = []
+ ; const self = this;
- runner.on('pending', function(test){
+ runner.on('pending', function(test) {
tests.push(test);
});
- runner.on('pass', function(test){
+ runner.on('pass', function(test) {
tests.push(test);
});
- runner.on('fail', function(test){
+ runner.on('fail', function(test) {
tests.push(test);
});
- runner.on('end', function(){
+ runner.on('end', function() {
console.log(tag('testsuite', {
- name: 'Mocha Tests'
- , tests: stats.tests
- , failures: stats.failures
- , errors: stats.failures
- , skipped: stats.tests - stats.failures - stats.passes
- , timestamp: (new Date).toUTCString()
- , time: (stats.duration / 1000) || 0
+ name: 'Mocha Tests',
+ tests: stats.tests,
+ failures: stats.failures,
+ errors: stats.failures,
+ skipped: stats.tests - stats.failures - stats.passes,
+ timestamp: (new Date).toUTCString(),
+ time: (stats.duration / 1000) || 0,
}, false));
tests.forEach(test);
@@ -75,14 +75,14 @@ XUnit.prototype.__proto__ = Base.prototype;
*/
function test(test) {
- var attrs = {
- classname: test.parent.fullTitle()
- , name: test.title
- , time: (test.duration / 1000) || 0
+ const attrs = {
+ classname: test.parent.fullTitle(),
+ name: test.title,
+ time: (test.duration / 1000) || 0,
};
if ('failed' == test.state) {
- var err = test.err;
+ const err = test.err;
attrs.message = escape(err.message);
console.log(tag('testcase', attrs, false, tag('failure', attrs, false, cdata(err.stack))));
} else if (test.pending) {
@@ -97,11 +97,11 @@ function test(test) {
*/
function tag(name, attrs, close, content) {
- var end = close ? '/>' : '>'
- , pairs = []
- , tag;
+ const end = close ? '/>' : '>'
+ ; const pairs = []
+ ; let tag;
- for (var key in attrs) {
+ for (const key in attrs) {
pairs.push(key + '="' + escape(attrs[key]) + '"');
}
diff --git a/test/mocha/lib/runnable.js b/test/mocha/lib/runnable.js
index 03b8792..5892035 100644
--- a/test/mocha/lib/runnable.js
+++ b/test/mocha/lib/runnable.js
@@ -3,25 +3,25 @@
* Module dependencies.
*/
-var EventEmitter = require('events').EventEmitter
- , debug = require('debug')('mocha:runnable')
- , milliseconds = require('./ms');
+const EventEmitter = require('events').EventEmitter
+ ; const debug = require('debug')('mocha:runnable')
+ ; const milliseconds = require('./ms');
/**
* Save timer references to avoid Sinon interfering (see GH-237).
*/
-var Date = global.Date
- , setTimeout = global.setTimeout
- , setInterval = global.setInterval
- , clearTimeout = global.clearTimeout
- , clearInterval = global.clearInterval;
+const Date = global.Date
+ ; const setTimeout = global.setTimeout
+ ; const setInterval = global.setInterval
+ ; const clearTimeout = global.clearTimeout
+ ; const clearInterval = global.clearInterval;
/**
* Object#toString().
*/
-var toString = Object.prototype.toString;
+const toString = Object.prototype.toString;
/**
* Expose `Runnable`.
@@ -61,7 +61,7 @@ Runnable.prototype.__proto__ = EventEmitter.prototype;
* @api private
*/
-Runnable.prototype.timeout = function(ms){
+Runnable.prototype.timeout = function(ms) {
if (0 == arguments.length) return this._timeout;
if ('string' == typeof ms) ms = milliseconds(ms);
debug('timeout %d', ms);
@@ -78,7 +78,7 @@ Runnable.prototype.timeout = function(ms){
* @api private
*/
-Runnable.prototype.slow = function(ms){
+Runnable.prototype.slow = function(ms) {
if (0 === arguments.length) return this._slow;
if ('string' == typeof ms) ms = milliseconds(ms);
debug('timeout %d', ms);
@@ -94,7 +94,7 @@ Runnable.prototype.slow = function(ms){
* @api public
*/
-Runnable.prototype.fullTitle = function(){
+Runnable.prototype.fullTitle = function() {
return this.parent.fullTitle() + ' ' + this.title;
};
@@ -104,7 +104,7 @@ Runnable.prototype.fullTitle = function(){
* @api private
*/
-Runnable.prototype.clearTimeout = function(){
+Runnable.prototype.clearTimeout = function() {
clearTimeout(this.timer);
};
@@ -115,8 +115,8 @@ Runnable.prototype.clearTimeout = function(){
* @api private
*/
-Runnable.prototype.inspect = function(){
- return JSON.stringify(this, function(key, val){
+Runnable.prototype.inspect = function() {
+ return JSON.stringify(this, function(key, val) {
if ('_' == key[0]) return;
if ('parent' == key) return '#%s
%s
%e', str)); - } + runner.on('suite', function(suite) { + if (suite.root) return; - // toggle code - // TODO: defer - if (!test.pending) { - var h2 = el.getElementsByTagName('h2')[0]; + // suite + const url = self.suiteURL(suite); + const el = fragment('
%e
', utils.clean(test.fn.toString()));
- el.appendChild(pre);
- pre.style.display = 'none';
- }
+ runner.on('suite end', function(suite) {
+ if (suite.root) return;
+ stack.shift();
+ });
+
+ runner.on('fail', function(test, err) {
+ if ('hook' == test.type) runner.emit('test end', test);
+ });
+
+ runner.on('test end', function(test) {
+ // TODO: add to stats
+ const percent = stats.tests / this.total * 100 | 0;
+ if (progress) progress.update(percent).draw(ctx);
+
+ // update stats
+ const ms = new Date - stats.start;
+ text(passes, stats.passes);
+ text(failures, stats.failures);
+ text(duration, (ms / 1000).toFixed(2));
+
+ // test
+ if ('passed' == test.state) {
+ const url = self.testURL(test);
+ var el = fragment('%e', str)); + } + + // toggle code + // TODO: defer + if (!test.pending) { + const h2 = el.getElementsByTagName('h2')[0]; + + on(h2, 'click', function() { + pre.style.display = 'none' == pre.style.display ? + 'block' : + 'none'; + }); + + var pre = fragment('
%e
', utils.clean(test.fn.toString()));
+ el.appendChild(pre);
+ pre.style.display = 'none';
+ }
-/**
+ // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.
+ if (stack[0]) stack[0].appendChild(el);
+ });
+ }
+
+ /**
* Provide suite URL
*
* @param {Object} [suite]
*/
-HTML.prototype.suiteURL = function(suite){
- return '?grep=' + encodeURIComponent(suite.fullTitle());
-};
+ HTML.prototype.suiteURL = function(suite) {
+ return '?grep=' + encodeURIComponent(suite.fullTitle());
+ };
-/**
+ /**
* Provide test URL
*
* @param {Object} [test]
*/
-HTML.prototype.testURL = function(test){
- return '?grep=' + encodeURIComponent(test.fullTitle());
-};
+ HTML.prototype.testURL = function(test) {
+ return '?grep=' + encodeURIComponent(test.fullTitle());
+ };
-/**
+ /**
* Display error `msg`.
*/
-function error(msg) {
- document.body.appendChild(fragment('Source: | " + escapeText( source ) + " |
---|
Source: | ' + escapeText( source ) + ' |
---|
Expected: | " + expected + " |
---|---|
Result: | " + actual + " |
Diff: | " + QUnit.diff( expected, actual ) + " |
Source: | " + escapeText( source ) + " |
Result: | " + escapeText( actual ) + " |
---|---|
Source: | " + escapeText( source ) + " |
Expected: | ' + expected + ' |
---|---|
Result: | ' + actual + ' |
Diff: | ' + QUnit.diff( expected, actual ) + ' |
Source: | ' + escapeText( source ) + ' |
Result: | ' + escapeText( actual ) + ' |
---|---|
Source: | ' + escapeText( source ) + ' |
Source: | " + escapeText( source ) + " |
---|
Source: | ' + escapeText( source ) + ' |
---|
Expected: | " + expected + " |
---|---|
Result: | " + actual + " |
Diff: | " + QUnit.diff( expected, actual ) + " |
Source: | " + escapeText( source ) + " |
Result: | " + escapeText( actual ) + " |
---|---|
Source: | " + escapeText( source ) + " |
Expected: | ' + expected + ' |
---|---|
Result: | ' + actual + ' |
Diff: | ' + QUnit.diff( expected, actual ) + ' |
Source: | ' + escapeText( source ) + ' |
Result: | ' + escapeText( actual ) + ' |
---|---|
Source: | ' + escapeText( source ) + ' |