I'm using a Jasmine (2.2.0) spy to see if a certain callback is called.
Test code:
it('tests', function(done) {
var spy = jasmine.createSpy('mySpy');
objectUnderTest.someFunction(spy).then(function() {
expect(spy).toHaveBeenCalled();
done();
});
});
This works as expected. But now, I'm adding a second level:
it('tests deeper', function(done) {
var spy = jasmine.createSpy('mySpy');
objectUnderTest.someFunction(spy).then(function() {
expect(spy).toHaveBeenCalled();
spy.reset();
return objectUnderTest.someFunction(spy);
}).then(function() {
expect(spy.toHaveBeenCalled());
expect(spy.callCount).toBe(1);
done();
});
});
This test never returns, because apparently the done
callback is never called. If I remove the line spy.reset()
, the test does finish, but obviously fails on the last expectation. However, the callCount
field seems to be undefined
, rather than 2
.