I have code like this:
it('should call json-rpc', function() {
var spy = spyOn(object, 'echo');
if (spy.andCallThrough) {
spy.andCallThrough();
} else {
spy.and.callThrough();
}
enter(term, 'echo foo bar');
setTimeout(function() {
// here I've got error Expected a spy, but got Function.
expect(object.echo).toHaveBeenCalledWith('foo', 'bar');
term.destroy().remove();
}, 200);
});
and I've got error that object.echo is not a spy but function, how can I check if function was called in setTimeout?
EDIT: I've tried use this:
if (jasmine.Clock) {
jasmine.Clock.useMock();
} else {
jasmine.clock().install();
}
and
if (jasmine.Clock) {
jasmine.Clock.tick(200);
} else {
jasmine.clock().tick(200);
}
expect(object.echo).toHaveBeenCalledWith('foo', 'bar');
but this also don't work. I've got error
Expected spy echo to have been called with [ 'foo', 'bar' ] but it was never called.