I have subsriber to an observable on ngOnInit and now I am trying to write test for this which doesn't seems working.
Here is my class which I am trying to test
ngOnInit() {
this.myService.updates$.pipe(takeUntil(unsusbribe$))
.subscribe(update => {
this.feeds = update;
})
}
Here is my unit test for this
it('should set feeds when an update is sent', fakeAsync(() => {
const update = 'fakeUpdate';
component.ngOnInit();
const serviceSpy = spyOn(myService, 'updates$').and.returnValue(timer(500).pipe(mapTo(update)))
tick(500);
expect(serviceSpy).toHaveBeenCalled();
}))
This test fails with error Expected spy updates$ to have been called.
Can anyone please help me figuring out the issue here.