Merge branch 'feat/improveErrorMessages' of https://github.com/dhoko/jasmine into dhoko-feat/improveErrorMessages
- Merges #1026 from @dhoko - Fixes #1025
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
getJasmineRequireObj().toHaveBeenCalled = function(j$) {
|
||||
|
||||
var getErrorMsg = j$.formatErrorMsg('<toHaveBeenCalled>', 'expect(<spyObj>).toHaveBeenCalled()');
|
||||
|
||||
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('Does not take arguments, use toHaveBeenCalledWith'));
|
||||
}
|
||||
|
||||
result.pass = actual.calls.any();
|
||||
|
||||
Reference in New Issue
Block a user