allow adding a deprecation object

This commit is contained in:
Tony Brix
2018-02-07 21:10:53 -06:00
parent 3d8e379fa6
commit a8a5b839ab
4 changed files with 22 additions and 12 deletions

View File

@@ -200,11 +200,11 @@ getJasmineRequireObj().Env = function(j$) {
handlingLoadErrors = false;
};
this.deprecated = function(msg) {
this.deprecated = function(deprecation) {
var runnable = currentRunnable() || topSuite;
runnable.addDeprecationWarning(msg);
if(typeof console !== 'undefined' && typeof console.warn !== 'undefined') {
console.error('DEPRECATION: ' + msg);
runnable.addDeprecationWarning(deprecation);
if(typeof console !== 'undefined' && typeof console.error === 'function') {
console.error('DEPRECATION:', deprecation);
}
};

View File

@@ -45,10 +45,14 @@ getJasmineRequireObj().buildExpectationResult = function() {
var error = options.error;
if (!error) {
try {
throw new Error(message());
} catch (e) {
error = e;
if (options.stack) {
error = options;
} else {
try {
throw new Error(message());
} catch (e) {
error = e;
}
}
}
return stackFormatter(error);

View File

@@ -152,8 +152,11 @@ getJasmineRequireObj().Spec = function(j$) {
return this.getSpecName(this);
};
Spec.prototype.addDeprecationWarning = function(msg) {
this.result.deprecationWarnings.push(this.expectationResultFactory({ message: msg }));
Spec.prototype.addDeprecationWarning = function(deprecation) {
if (typeof deprecation === 'string') {
deprecation = { message: deprecation };
}
this.result.deprecationWarnings.push(this.expectationResultFactory(deprecation));
};
var extractCustomPendingMessage = function(e) {

View File

@@ -148,8 +148,11 @@ getJasmineRequireObj().Suite = function(j$) {
}
};
Suite.prototype.addDeprecationWarning = function(msg) {
this.result.deprecationWarnings.push(this.expectationResultFactory({ message: msg }));
Suite.prototype.addDeprecationWarning = function(deprecation) {
if (typeof deprecation === 'string') {
deprecation = { message: deprecation };
}
this.result.deprecationWarnings.push(this.expectationResultFactory(deprecation));
};
function isFailure(args) {