The below method calls CheckLastEmployee method which returns true/false.
async nextEmployee(empId:number) {
let isLast;
await this.CheckLastEmployee(empId).then(x=>{isLast=x});
if (isLast) {
Submit();
}
}
More logic inside CheckLastEmployee....copied a part of the code..
async CheckLastEmployee(empId:number){
let enrollment = new Map<string, boolean>();
await this.GetEnrolledPrograms().then(res => enrollment = res);
if(empId==10)
return true;
else
return false;
}
Test case .spec.ts
it('Is Last Employee-submit',()=>{
spyOn(component,'CheckLastEmployee').and.returnValue(Promise.resolve(true));
spyOn(component,'Submit');
component.nextEmployee(10);
expect(component.Submit).toHaveBeenCalled();
}
the above test case fails.