So I have an Ionic project and I want to write unit tests for the PhotoService. I am using the following for my implementation: https://capacitorjs.com/docs/apis/camera#type-162695.
In my PhotoService file I have a method for getting a Photo. In this case it gets the photo from taking a picture.
getPhoto(): Observable<CameraPhoto> {
const options: CameraOptions = {
quality:
allowEditing:
resultType: CameraResultType:Base64
source: CameraSource.Camera
}
return defer(() => Camera.getPhoto(options))
}
How do I test this? So far I've been using jasmine.spyOn to do basic stuff like check that it has been called but how would I mock the a photo taken? Any insight on this would be very helpful!
Aucun commentaire:
Enregistrer un commentaire