import "@testing-library/jest-dom/vitest";
import { cleanup } from "@testing-library/react";
import { afterEach } from "vitest";

/** lottie-web 載入時會摸 canvas；jsdom 的 getContext 會丟 Not implemented。 */
HTMLCanvasElement.prototype.getContext = function getContext(this: HTMLCanvasElement) {
  return {
    fillStyle: "",
    fillRect() {},
    drawImage() {},
    getImageData() {
      return { data: new Uint8ClampedArray(4) };
    },
    canvas: this,
  };
} as unknown as typeof HTMLCanvasElement.prototype.getContext;

afterEach(() => {
  cleanup();
});
