50 lines
2.3 KiB
TypeScript
50 lines
2.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { applyCopy, DEFAULT_COPY_ITEMS, planCopy } from '../src/core/copy';
|
|
import type { PierInput } from '../src/core/types';
|
|
import { loadP1 } from './helpers';
|
|
|
|
const source = (): PierInput => ({ ...loadP1(), copingWidthMm: 3300, pileLengthMm: 20000, copingLengthMm: 11000 });
|
|
const target = (): PierInput => ({ ...loadP1(), name: 'P2', copingWidthMm: 3100, pileLengthMm: 24000, copingLengthMm: 12000 });
|
|
|
|
describe('속성 복사 engine (spec §9, plan C7)', () => {
|
|
it('defaults copy only the coping width; length items are off', () => {
|
|
expect(DEFAULT_COPY_ITEMS).toEqual(['coping-width']);
|
|
const plan = planCopy(source(), target(), DEFAULT_COPY_ITEMS);
|
|
expect(plan.changes).toEqual([{ key: 'copingWidthMm', from: 3100, to: 3300 }]);
|
|
});
|
|
|
|
it('identity, coordinates, IPs, bearings and elevations are never copied', () => {
|
|
const src = { ...source(), name: 'X', ips: [], bearings: [], copingTopEl: 99, groundEl: 99, footingBottomEl: 99 };
|
|
const tgt = target();
|
|
const next = applyCopy(tgt, planCopy(src, tgt, ['coping-width', 'coping-length', 'pile-length']));
|
|
expect(next.name).toBe('P2');
|
|
expect(next.ips).toEqual(tgt.ips);
|
|
expect(next.bearings).toEqual(tgt.bearings);
|
|
expect(next.copingTopEl).toBe(tgt.copingTopEl);
|
|
expect(next.groundEl).toBe(tgt.groundEl);
|
|
expect(next.footingBottomEl).toBe(tgt.footingBottomEl);
|
|
});
|
|
|
|
it('a pile item is skipped when the foundation type differs', () => {
|
|
const tgt = { ...target(), foundationType: '직접기초' as const };
|
|
const plan = planCopy(source(), tgt, ['pile-length']);
|
|
expect(plan.changes).toEqual([]);
|
|
expect(plan.skipped).toEqual([{ item: 'pile-length', reason: '기초 형식이 다릅니다 (직접기초)' }]);
|
|
});
|
|
|
|
it('equal values are not counted as changes', () => {
|
|
const src = source();
|
|
const tgt = { ...target(), copingWidthMm: 3300 };
|
|
expect(planCopy(src, tgt, ['coping-width']).changes).toEqual([]);
|
|
});
|
|
|
|
it('the preview count equals the number of applied changes', () => {
|
|
const plan = planCopy(source(), target(), ['coping-width', 'coping-length', 'pile-length']);
|
|
const next = applyCopy(target(), plan);
|
|
expect(plan.changes).toHaveLength(3);
|
|
expect(next.copingWidthMm).toBe(3300);
|
|
expect(next.copingLengthMm).toBe(11000);
|
|
expect(next.pileLengthMm).toBe(20000);
|
|
});
|
|
});
|