concat files for toHaveBeenCalledTimes matcher
This commit is contained in:
parent
79954311fb
commit
cd55f03912
@@ -93,6 +93,7 @@ getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
||||
'toEqual',
|
||||
'toHaveBeenCalled',
|
||||
'toHaveBeenCalledWith',
|
||||
'toHaveBeenCalledTimes',
|
||||
'toMatch',
|
||||
'toThrow',
|
||||
'toThrowError'
|
||||
@@ -2982,6 +2983,37 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
|
||||
return toHaveBeenCalled;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
||||
|
||||
function toHaveBeenCalledTimes() {
|
||||
return {
|
||||
compare: function(actual, expected) {
|
||||
if (!j$.isSpy(actual)) {
|
||||
throw new Error('Expected a spy, but got ' + j$.pp(actual) + '.');
|
||||
}
|
||||
|
||||
var args = Array.prototype.slice.call(arguments, 0),
|
||||
result = { pass: false };
|
||||
|
||||
if(!expected){
|
||||
throw new Error('Expected times failed is required as an argument.');
|
||||
}
|
||||
|
||||
actual = args[0];
|
||||
var calls = actual.calls.count();
|
||||
var timesMessage = expected === 1 ? 'once' : expected + ' times';
|
||||
result.pass = calls === expected;
|
||||
result.message = result.pass ?
|
||||
'Expected spy ' + actual.and.identity() + ' not to have been called ' + timesMessage + '. It was called ' + calls + ' times.' :
|
||||
'Expected spy ' + actual.and.identity() + ' to have been called ' + timesMessage + '. It was called ' + calls + ' times.';
|
||||
return result;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
return toHaveBeenCalledTimes;
|
||||
};
|
||||
|
||||
getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
||||
|
||||
function toHaveBeenCalledWith(util, customEqualityTesters) {
|
||||
|
||||
Reference in New Issue
Block a user