aryan1306
aryan1306
TTCTheo's Typesafe Cult
Created by aryan1306 on 10/15/2022 in #questions
Needed help to write unit test for image download
Hey there, I wanted to write test for the handleShareClick function, this function uses html2canvas lib and I am not sure how I acna write a unit test using jest. PS I am new to testing. Here is the code: const handleShareClick = () => {     html2canvas(document.querySelector('#share')!).then(canvas => {       const dataURL = canvas.toDataURL();       const a = document.createElement('a');       a.setAttribute('download', `${Math.floor(Date.now() / 1000)}-success`);       a.setAttribute('href', dataURL);       a.click();     });   };
3 replies