vitest-webgl-canvas-mock
Version:
Mock both 2D and WebGL contexts in Vitest.
19 lines (18 loc) • 688 B
JavaScript
/**
* This function returns a CanvasRenderingContext2DEvent. Whenever an operation would modify the canvas
* context, this function should be used to generate an "event" that represents that sort of modification.
* This will be used to mock for snapshots.
*
* @example
* interface CanvasRenderingContext2DEvent {
* type: string;
* transform: [number, number, number, number, number, number]; // the resulting current transform
* props: {
* // if the event is a property was set, `event.props.value` would be set
* [propName: string]: any;
* };
* }
*/
export default function createCanvasEvent(type, transform, props) {
return { type, transform, props };
}