87 lines
1.6 KiB
TypeScript
87 lines
1.6 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { duplicateShapeWithLabel } from '../../src/features/layout/draw/layoutDrawShapeUtils.ts';
|
|
|
|
test('duplicates a line with original label when no override is provided', () => {
|
|
const duplicated = duplicateShapeWithLabel(
|
|
{
|
|
id: 'line-1',
|
|
type: 'line',
|
|
x1: 10,
|
|
y1: 20,
|
|
x2: 10,
|
|
y2: 160,
|
|
orientation: 'vertical',
|
|
label: '기존',
|
|
},
|
|
'line-2',
|
|
);
|
|
|
|
assert.deepEqual(duplicated, {
|
|
id: 'line-2',
|
|
type: 'line',
|
|
x1: 34,
|
|
y1: 44,
|
|
x2: 34,
|
|
y2: 184,
|
|
orientation: 'vertical',
|
|
label: '기존',
|
|
});
|
|
});
|
|
|
|
test('duplicates a line with label override and offset', () => {
|
|
const duplicated = duplicateShapeWithLabel(
|
|
{
|
|
id: 'line-1',
|
|
type: 'line',
|
|
x1: 10,
|
|
y1: 20,
|
|
x2: 10,
|
|
y2: 160,
|
|
orientation: 'vertical',
|
|
label: '기존',
|
|
},
|
|
'line-2',
|
|
'복사본',
|
|
);
|
|
|
|
assert.deepEqual(duplicated, {
|
|
id: 'line-2',
|
|
type: 'line',
|
|
x1: 34,
|
|
y1: 44,
|
|
x2: 34,
|
|
y2: 184,
|
|
orientation: 'vertical',
|
|
label: '복사본',
|
|
});
|
|
});
|
|
|
|
test('duplicates a rect with label override and offset', () => {
|
|
const duplicated = duplicateShapeWithLabel(
|
|
{
|
|
id: 'rect-1',
|
|
type: 'rect',
|
|
x: 40,
|
|
y: 50,
|
|
width: 120,
|
|
height: 80,
|
|
label: '사각형',
|
|
fillColor: '#bfdbfe',
|
|
},
|
|
'rect-2',
|
|
'새 라벨',
|
|
);
|
|
|
|
assert.deepEqual(duplicated, {
|
|
id: 'rect-2',
|
|
type: 'rect',
|
|
x: 64,
|
|
y: 74,
|
|
width: 120,
|
|
height: 80,
|
|
label: '새 라벨',
|
|
fillColor: '#bfdbfe',
|
|
});
|
|
});
|