Matchers & Matchers specs now broken up into individual files. There is now a requireMatchers jasmineRequire function to attach matchers properly.
This commit is contained in:
28
src/core/matchers/toHaveBeenCalled.js
Normal file
28
src/core/matchers/toHaveBeenCalled.js
Normal file
@@ -0,0 +1,28 @@
|
||||
getJasmineRequireObj().toHaveBeenCalled = function() {
|
||||
|
||||
function toHaveBeenCalled() {
|
||||
return {
|
||||
compare: function(actual) {
|
||||
var result = {};
|
||||
|
||||
if (!j$.isSpy(actual)) {
|
||||
throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.');
|
||||
}
|
||||
|
||||
if (arguments.length > 1) {
|
||||
throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
|
||||
}
|
||||
|
||||
result.pass = actual.wasCalled;
|
||||
|
||||
result.message = result.pass ?
|
||||
"Expected spy " + actual.identity + " not to have been called." :
|
||||
"Expected spy " + actual.identity + " to have been called.";
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return toHaveBeenCalled;
|
||||
};
|
||||
Reference in New Issue
Block a user