I'm currently trying to test some Promise heavy functions in the codebase. This snippet also has the added joy of an event listener as well.
How would I go about testing this?
const createImage = url =>
new Promise((resolve, reject) => {
const image = new Image();
image.addEventListener("load", () => resolve(image));
image.addEventListener("error", error => reject(error));
image.setAttribute("crossOrigin", "anonymous"); // needed to avoid cross-origin issues on CodeSandbox
image.src = url;
});
export default createImage;