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

View File

@@ -1,16 +1,18 @@
getJasmineRequireObj().toHaveBeenCalled = function(j$) {
var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalled>', 'expect(<spyObj>).toHaveBeenCalled()', 'To test with arguments, you can use <toHaveBeenCalledWith>');
function toHaveBeenCalled() {
return {
compare: function(actual) {
var result = {};
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) + '.'));
}
if (arguments.length > 1) {
throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
throw new Error(getErrorMsg('It does not take arguments, use toHaveBeenCalledWith'));
}
result.pass = actual.calls.any();