Improve errors with the domaine and how to use the API
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user