Improve errors with the domaine and how to use the API
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
||||
|
||||
var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalledTimes>', 'expect(<spyObj>).toHaveBeenCalledTimes(<Number>)');
|
||||
|
||||
function toHaveBeenCalledTimes() {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
if (!j$.isSpy(actual)) {
|
||||
throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.');
|
||||
throw new Error(getErrorMsg('Expected a spy, but got ' + j$.pp(actual) + '.'));
|
||||
}
|
||||
|
||||
var args = Array.prototype.slice.call(arguments, 0),
|
||||
result = { pass: false };
|
||||
|
||||
if (!j$.isNumber_(expected)){
|
||||
throw new Error('The expected times failed is a required argument and must be a number.');
|
||||
throw new Error(getErrorMsg('The expected times failed is a required argument and must be a number.'));
|
||||
}
|
||||
|
||||
actual = args[0];
|
||||
@@ -27,4 +29,4 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
||||
}
|
||||
|
||||
return toHaveBeenCalledTimes;
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user