get group resize, enter and exit working
This commit is contained in:
26
frontend/tests/groupDrag.test.mjs
Normal file
26
frontend/tests/groupDrag.test.mjs
Normal file
@@ -0,0 +1,26 @@
|
||||
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,
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user