I'm trying to write a unit test with 100% code coverage (line) and I'm stuck with the following code snippet:
getValuesPeriodically(updateInterval: number) {
interval(updateInterval)
.subscribe(() =>
this.getFilesFromService()
);
}
I don't know how to cover this part:
() =>
this.getFilesFromService()
I tried implementing a unit test with fakeAsync and tick(), but the async gave me an error message:
it('timer test', fakeAsync(() => {
fixture.detectChanges();
expect(component.filesData.length).toBe(0);
tick(1000);
fixture.detectChanges();
expect(component.filesData.length).toBeGreaterThan(0);
}));
I get the following error:
TypeError: Cannot read property 'assertPresent' of null
I'm not sure if this is the right way to cover the missing part of my unit test anyways.
Can you help please?