Files
tono/frontend/tests/groupDrag.test.mjs
2026-03-27 14:13:09 -07:00

27 lines
798 B
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import {
GROUP_DRAG_RELEASE_DISTANCE,
getPointDistanceOutsideRect,
shouldReleaseFromGroup,
} from '../src/groupDrag.js';
test('getPointDistanceOutsideRect returns zero inside the rect', () => {
const rect = { left: 10, top: 20, right: 110, bottom: 120 };
assert.equal(getPointDistanceOutsideRect(rect, { x: 60, y: 70 }), 0);
});
test('shouldReleaseFromGroup waits for a small overshoot before releasing', () => {
const rect = { left: 10, top: 20, right: 110, bottom: 120 };
assert.equal(
shouldReleaseFromGroup(rect, { x: 110 + GROUP_DRAG_RELEASE_DISTANCE - 1, y: 70 }),
false,
);
assert.equal(
shouldReleaseFromGroup(rect, { x: 110 + GROUP_DRAG_RELEASE_DISTANCE, y: 70 }),
true,
);
});