fixup! Add toHaveBeenCalledBefore matcher
This commit is contained in:
@@ -23,12 +23,24 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result.pass = firstSpy.calls.mostRecent().invocationOrder < latterSpy.calls.mostRecent().invocationOrder;
|
||||
var latest1stSpyCall = firstSpy.calls.mostRecent().invocationOrder;
|
||||
var first2ndSpyCall = latterSpy.calls.first().invocationOrder;
|
||||
|
||||
result.pass = latest1stSpyCall < first2ndSpyCall;
|
||||
|
||||
if (result.pass) {
|
||||
result.message = 'Expected ' + firstSpy.and.identity() + ' to not have been called before ' + latterSpy.and.identity() + ', but it was';
|
||||
result.message = 'Expected spy ' + firstSpy.and.identity() + ' to not have been called before spy ' + latterSpy.and.identity() + ', but it was';
|
||||
} else {
|
||||
result.message = 'Expected ' + firstSpy.and.identity() + ' to have been called before ' + latterSpy.and.identity();
|
||||
var first1stSpyCall = firstSpy.calls.first().invocationOrder;
|
||||
var latest2ndSpyCall = latterSpy.calls.mostRecent().invocationOrder;
|
||||
|
||||
if(first1stSpyCall < first2ndSpyCall) {
|
||||
result.message = 'Expected latest call to spy ' + firstSpy.and.identity() + ' to have been called before first call to spy ' + latterSpy.and.identity() + ' (no interleaved calls)';
|
||||
} else if (latest2ndSpyCall > latest1stSpyCall) {
|
||||
result.message = 'Expected first call to spy ' + latterSpy.and.identity() + ' to have been called after latest call to spy ' + firstSpy.and.identity() + ' (no interleaved calls)';
|
||||
} else {
|
||||
result.message = 'Expected spy ' + firstSpy.and.identity() + ' to have been called before spy ' + latterSpy.and.identity();
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user