get group resize, enter and exit working
This commit is contained in:
8
frontend/tests/constants.test.mjs
Normal file
8
frontend/tests/constants.test.mjs
Normal file
@@ -0,0 +1,8 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import { SOCKET_COMPATIBILITY } from '../src/constants.js';
|
||||
|
||||
test('SAVE_VALUE accepts ANNOTATION_SOURCE inputs', () => {
|
||||
assert.equal(SOCKET_COMPATIBILITY.SAVE_VALUE.has('ANNOTATION_SOURCE'), true);
|
||||
});
|
||||
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,
|
||||
);
|
||||
});
|
||||
26
frontend/tests/groupSizing.test.mjs
Normal file
26
frontend/tests/groupSizing.test.mjs
Normal file
@@ -0,0 +1,26 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
|
||||
import { getGroupMinimumSize } from '../src/groupSizing.js';
|
||||
|
||||
test('getGroupMinimumSize keeps the base minimum for empty groups', () => {
|
||||
assert.deepEqual(getGroupMinimumSize([]), { width: 260, height: 180 });
|
||||
});
|
||||
|
||||
test('getGroupMinimumSize grows to fit child bounds plus padding', () => {
|
||||
const nodes = [
|
||||
{
|
||||
position: { x: 24, y: 60 },
|
||||
style: { width: 180, height: 100 },
|
||||
},
|
||||
{
|
||||
position: { x: 260, y: 150 },
|
||||
style: { width: 220, height: 140 },
|
||||
},
|
||||
];
|
||||
|
||||
assert.deepEqual(getGroupMinimumSize(nodes), {
|
||||
width: 504,
|
||||
height: 314,
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user