I have trouble getting a jasmine test to run the way I want it to. The test result is Expected spy _cancelInterval to have been called. even though the _clearInterval function is being called.
The test looks as follows:
it('should clear the interval after receiving unknown error', (done) => {
// simulate backend sending unknown error
communicationServiceMock['GET'] = () => Observable.throw(new Error('Unknown Error'));
subjectService = new ProcessQueueService(communicationServiceMock);
spyOn(subjectService, '_cancelInterval').and.callThrough();
subjectService.addProcessByStatusUrl('').statusObservable
.skip(1)
.subscribe(
(status) => {
expect(subjectService._cancelInterval).toHaveBeenCalled();
done();
}
)
// advance one polling interval and just a little bit
jasmine.clock().tick(DEFAULT_POLLING_INTERVAL * 2 + 10);
});
Am I doing anything fundamentally wrong? My first approach was to spy on the window.clearInterval which is internally called in the _cancelInterval function, but that threw even more errors.
Aucun commentaire:
Enregistrer un commentaire