MCPcopy
hub / github.com/coder/mux / createMockCanvas

Function createMockCanvas

src/browser/utils/imageResize.test.ts:34–54  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32}
33
34function createMockCanvas(): HTMLCanvasElement {
35 return {
36 width: 0,
37 height: 0,
38 getContext: (contextType: string) => {
39 if (contextType !== "2d") {
40 return null;
41 }
42
43 return {
44 drawImage: (_image: unknown, _x: number, _y: number, width: number, height: number) => {
45 drawImageCalls.push({ width, height });
46 },
47 } as unknown as CanvasRenderingContext2D;
48 },
49 toDataURL: (type?: string, quality?: number) => {
50 toDataUrlCalls.push({ type, quality });
51 return `data:${type ?? "image/png"};base64,resized`;
52 },
53 } as unknown as HTMLCanvasElement;
54}
55
56beforeEach(() => {
57 mockImageWidth = 0;

Callers 1

Calls 1

pushMethod · 0.65

Tested by

no test coverage detected