@ohos-ports/vi-canvas-mock 1.0.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,96 @@
1
+ export function setupVitestCanvasMock(window?: Window) {}
2
+
3
+ export interface CanvasRenderingContext2DEvent {
4
+ /**
5
+ * This is the type of canvas event that occurred.
6
+ */
7
+ type: string;
8
+ /**
9
+ * This is a six element array that contains the current state of the canvas `currentTransform`
10
+ * value.
11
+ */
12
+ transform: [number, number, number, number, number, number];
13
+ /**
14
+ * These are the relevant properties related to this canvas event.
15
+ */
16
+ props: {
17
+ [key: string]: any;
18
+ };
19
+ }
20
+
21
+ declare global {
22
+ interface CanvasRenderingContext2D {
23
+ /**
24
+ * Get all the events associated with this CanvasRenderingContext2D object.
25
+ *
26
+ * This method cannot be used in a production environment, only with `vitest` using
27
+ * `vi-canvas-mock` and should only be used for testing.
28
+ *
29
+ * @example
30
+ * expect(ctx.__getEvents()).toMatchSnapshot();
31
+ */
32
+ __getEvents(): CanvasRenderingContext2DEvent[];
33
+
34
+ /**
35
+ * Clear all the events associated with this CanvasRenderingContext2D object.
36
+ *
37
+ * This method cannot be used in a production environment, only with `vitest` using
38
+ * `vi-canvas-mock` and should only be used for testing.
39
+ *
40
+ * @example
41
+ * ctx.__clearEvents());
42
+ * expect(ctx.__getEvents()).toBe([]);
43
+ */
44
+ __clearEvents(): void;
45
+
46
+ /**
47
+ * Get all the successful draw calls associated with this CanvasRenderingContext2D object.
48
+ *
49
+ * This method cannot be used in a production environment, only with `vitest` using
50
+ * `vi-canvas-mock` and should only be used for testing.
51
+ *
52
+ * @example
53
+ * expect(ctx.__getDrawCalls()).toMatchSnapshot();
54
+ */
55
+ __getDrawCalls(): CanvasRenderingContext2DEvent[];
56
+
57
+ /**
58
+ * Clear all the successful draw calls associated with this CanvasRenderingContext2D object.
59
+ *
60
+ * This method cannot be used in a production environment, only with `vitest` using
61
+ * `vi-canvas-mock` and should only be used for testing.
62
+ *
63
+ * @example
64
+ * ctx.__clearDrawCalls());
65
+ * expect(ctx.__getDrawCalls()).toBe([]);
66
+ */
67
+ __clearDrawCalls(): void;
68
+
69
+ /**
70
+ * Get the current path associated with this CanvasRenderingContext2D object.
71
+ *
72
+ * This method cannot be used in a production environment, only with `vitest` using
73
+ * `vi-canvas-mock` and should only be used for testing.
74
+ *
75
+ * @example
76
+ * expect(ctx.__getPath()).toMatchSnapshot();
77
+ */
78
+ __getPath(): CanvasRenderingContext2DEvent[];
79
+
80
+ /**
81
+ * Clears the current path associated with this CanvasRenderingContext2D object.
82
+ *
83
+ * This method cannot be used in a production environment, only with `vitest` using
84
+ * `vi-canvas-mock` and should be only used for testing.
85
+ */
86
+ __clearPath(): void;
87
+
88
+ /**
89
+ * Obtains the current clipping path.
90
+ *
91
+ * This method cannot be used in a production environment, only with `vitest` using
92
+ * `vi-canvas-mock` and should be only used for testing.
93
+ */
94
+ __getClippingRegion(): CanvasRenderingContext2DEvent[];
95
+ }
96
+ }