Restore custom failure messages for toHaveBeenCalledWith
As pointed out by @tjgrathwell
This commit is contained in:
@@ -5,21 +5,26 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
||||
compare: function() {
|
||||
var args = Array.prototype.slice.call(arguments, 0),
|
||||
actual = args[0],
|
||||
expectedArgs = args.slice(1);
|
||||
expectedArgs = args.slice(1),
|
||||
result = { pass: false };
|
||||
|
||||
if (!j$.isSpy(actual)) {
|
||||
throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.');
|
||||
}
|
||||
|
||||
return {
|
||||
pass: util.contains(actual.calls.allArgs(), expectedArgs)
|
||||
};
|
||||
},
|
||||
message: function(actual) {
|
||||
return {
|
||||
affirmative: "Expected spy " + actual.and.identity() + " to have been called.",
|
||||
negative: "Expected spy " + actual.and.identity() + " not to have been called."
|
||||
};
|
||||
if (!actual.calls.any()) {
|
||||
result.message = "Expected spy " + actual.and.identity() + " to have been called with " + j$.pp(expectedArgs) + " but it was never called.";
|
||||
return result;
|
||||
}
|
||||
|
||||
if (util.contains(actual.calls.allArgs(), expectedArgs)) {
|
||||
result.pass = true;
|
||||
result.message = "Expected spy " + actual.and.identity() + " not to have been called with " + j$.pp(expectedArgs) + " but it was.";
|
||||
} else {
|
||||
result.message = "Expected spy " + actual.and.identity() + " to have been called with " + j$.pp(expectedArgs) + " but actual calls were " + j$.pp(actual.calls.allArgs()).replace(/^\[ | \]$/g, '') + ".";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user