I\'m having difficulties with a unit test in which I want to verify the processing of a file, which would usually be selected in the view via
Here is an example spec for input file/image using angular2+.
it('should call showError on toastService Api on call of onSaveOfImage() method', () => {
spyOn(component.commonFacade.fileIOApi, 'uploadFile');
let file = new File([new ArrayBuffer(2e+5)], 'test-file.jpg', { lastModified: null, type: 'image/jpeg' });
let fileInput={ files: [file] };
component['onSaveOfImage'](fileInput,"",null,"","");
expect(component.commonFacade.fileIOApi.uploadFile).toHaveBeenCalledTimes(1);
expect(component.uploadedFileData).toBeUndefined();
expect(component.commonFacade.employeeApi.toastService.showError).toHaveBeenCalledTimes(1);
})