2

.ts file

generateQRCode(data){
     let reader = new FileReader();
     reader.readAsDataURL(data);
     reader.onload = ()=>{
       this.QRcode = reader.result;
     }
   }

.spec.ts file

it('generateQRCode',()=>{
     const fakeFile = new File([new Blob(['123'])], 'abc.gif',{type:'image/gif'})
     component.generateQRCode(fakeFile)
     **expect(component.QRcode).toBeDefined();**
   })

how to "component.QRcode" will be defined in the test file

Soura Ghosh
  • 879
  • 1
  • 9
  • 16
  • Check out NVCoder's answer here: https://stackoverflow.com/questions/15212348/how-do-i-write-filereader-test-in-jasmine – AliF50 Oct 09 '20 at 19:55

0 Answers0