I have the following service subscription which is promise
getTaskData = async() {
line 1 let response = this.getTaskSV.getTaskData().toPromise();
line 2 this.loading = false;
}
I tried like below,
it('should load getTaskData', async () => {
let getTaskSV= TestBed.inject(getTaskSV);
spyOn(getTaskSV, 'getTaskData').and.returnValue(of([{name: 'test1'}, {name: 'test2'}]));
component.getTaskData();
fixture.detectChanges()
});
When I run the above test case I see the line 1 and 2 are not covered. I am actually new to the test cases. Can any one please help me how to mock this service. Thanks in advance.