Made output of toHaveBeenCalledWith more readable
This breaks each call out onto its own line, so that it's much easier to
see where each call starts and how they differ. E.g. previously the output
would be:
Expected spy foo to have been called with [ 'bar', 'baz', 'qux' ] but actual calls were [ [ 42, 'wibble' ], [ 'bar' 'qux' ], [ 'grault '] ]
Now it's:
Expected spy foo to have been called with:
[ 'bar', 'baz', 'qux' ]
but actual calls were:
[ 42, 'wibble' ],
[ 'bar' 'qux' ],
[ 'grault '].
This commit is contained in:
@@ -24,15 +24,32 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
||||
}
|
||||
|
||||
if (!actual.calls.any()) {
|
||||
result.message = function() { return 'Expected spy ' + actual.and.identity + ' to have been called with ' + j$.pp(expectedArgs) + ' but it was never called.'; };
|
||||
result.message = function() {
|
||||
return 'Expected spy ' + actual.and.identity + ' to have been called with:\n' +
|
||||
' ' + j$.pp(expectedArgs) +
|
||||
'\nbut it was never called.';
|
||||
};
|
||||
return result;
|
||||
}
|
||||
|
||||
if (util.contains(actual.calls.allArgs(), expectedArgs, customEqualityTesters)) {
|
||||
result.pass = true;
|
||||
result.message = function() { return 'Expected spy ' + actual.and.identity + ' not to have been called with ' + j$.pp(expectedArgs) + ' but it was.'; };
|
||||
result.message = function() {
|
||||
return 'Expected spy ' + actual.and.identity + ' not to have been called with:\n' +
|
||||
' ' + j$.pp(expectedArgs) +
|
||||
'\nbut it was.';
|
||||
};
|
||||
} else {
|
||||
result.message = function() { return 'Expected spy ' + actual.and.identity + ' to have been called with ' + j$.pp(expectedArgs) + ' but actual calls were ' + j$.pp(actual.calls.allArgs()).replace(/^\[ | \]$/g, '') + '.'; };
|
||||
result.message = function() {
|
||||
var prettyPrintedCalls = actual.calls.allArgs().map(function(argsForCall) {
|
||||
return ' ' + j$.pp(argsForCall);
|
||||
});
|
||||
|
||||
return 'Expected spy ' + actual.and.identity + ' to have been called with:\n' +
|
||||
' ' + j$.pp(expectedArgs) + '\n' + '' +
|
||||
'but actual calls were:\n' +
|
||||
prettyPrintedCalls.join(',\n') + '.';
|
||||
};
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user