Improve errors with the domaine and how to use the API

This commit is contained in:
dhoko
2016-01-20 15:49:47 +01:00
parent b6798cdb06
commit 14067d0785
16 changed files with 131 additions and 28 deletions
+5 -3
View File
@@ -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;
};
};