I have an Angular component that has a method:
async update(myObject: IMyObject) {
await this.myService
.update(myObject)
.toPromise()
.then(updatedObject => {
this.myObject = updatedObject.body;
});
}
I am trying to write a unit test can cover the then part as well.
The async/await part makes it more difficult to test, I get a timeout after trying with the most common approaches.
The only thing that worked was:
const spyObj = spyOn(myService, 'update').and.callFake(() => {
return Promise.resolve();
});
But obviously, that is not what I was looking for.
I would highly appreciate if you could point me in the correct direction.