refactor(web): split touch canvas adapters
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { createTouchCanvasPointerEvent, createTouchMouseDownEvent } from "./timelineTouchAdapters.js";
|
||||
|
||||
describe("timelineTouchAdapters", () => {
|
||||
it("creates a primary-button mouse-down adapter for touch handlers", () => {
|
||||
const currentTarget = new EventTarget();
|
||||
|
||||
expect(createTouchMouseDownEvent({ clientX: 42, clientY: 17 }, currentTarget)).toMatchObject({
|
||||
button: 0,
|
||||
clientX: 42,
|
||||
currentTarget,
|
||||
shiftKey: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("allows missing targets when creating a touch mouse-down adapter", () => {
|
||||
const event = createTouchMouseDownEvent({ clientX: 7, clientY: 9 });
|
||||
|
||||
expect(event.currentTarget).toBeNull();
|
||||
expect(() => {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
it("creates a canvas pointer event with both coordinates preserved", () => {
|
||||
expect(createTouchCanvasPointerEvent({ clientX: 21, clientY: 34 })).toEqual({
|
||||
clientX: 21,
|
||||
clientY: 34,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user