33 lines
856 B
TypeScript
33 lines
856 B
TypeScript
import { expect, test } from "@playwright/test";
|
|
import {
|
|
CANVAS_GRID_SNAP_SIZE,
|
|
resolveCanvasGridSnapPosition,
|
|
} from "@/lib/canvas/grid-snap";
|
|
|
|
test.describe("video canvas grid snap", () => {
|
|
test("snaps drag displacement to ten world units without changing the node origin offset", () => {
|
|
expect(CANVAS_GRID_SNAP_SIZE).toBe(10);
|
|
expect(
|
|
resolveCanvasGridSnapPosition({
|
|
deltaX: 38,
|
|
deltaY: 34,
|
|
enabled: true,
|
|
startX: 6504,
|
|
startY: 60,
|
|
})
|
|
).toEqual({ x: 6544, y: 90 });
|
|
});
|
|
|
|
test("keeps free dragging on integer world coordinates when snapping is disabled", () => {
|
|
expect(
|
|
resolveCanvasGridSnapPosition({
|
|
deltaX: 38.2,
|
|
deltaY: 35.7,
|
|
enabled: false,
|
|
startX: 6504,
|
|
startY: 60,
|
|
})
|
|
).toEqual({ x: 6542, y: 96 });
|
|
});
|
|
});
|