- 체크 = 활성: 체크된 교각(모델 있는 것)과 기준 교각을 3D에 함께 표시 - ② 형상계획도 활성 교각이 2기 이상이면 같은 좌표계로 배치 - 이름 클릭 = 기준 교각: 코핑·말뚝 수정 카드의 대상 - '활성 교각에 적용': 기준 교각의 변경 항목만 다른 활성 교각에 복사 (확인 후, 다시 생성으로 반영) - 입력값 표: 활성 교각 행 음영, 기준 교각 굵게 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
55 lines
2.1 KiB
TypeScript
55 lines
2.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { applyOverrides, overrideTargets, shownNames, type PierSelection } from '../src/core/active-piers';
|
|
import { loadP1 } from './helpers';
|
|
|
|
const list: PierSelection[] = [
|
|
{ name: 'P1', checked: true, hasModel: true },
|
|
{ name: 'P2', checked: true, hasModel: true },
|
|
{ name: 'P3', checked: false, hasModel: true },
|
|
{ name: 'P4', checked: true, hasModel: false },
|
|
];
|
|
|
|
describe('shownNames (체크 = 활성, 기준 교각은 항상 표시)', () => {
|
|
it('shows every checked pier that has a model, in list order', () => {
|
|
expect(shownNames(list, 'P1')).toEqual(['P1', 'P2']);
|
|
});
|
|
|
|
it('keeps the 기준 pier even when it is unchecked', () => {
|
|
expect(shownNames(list, 'P3')).toEqual(['P1', 'P2', 'P3']);
|
|
});
|
|
|
|
it('never shows a pier without a model', () => {
|
|
expect(shownNames(list, 'P4')).toEqual(['P1', 'P2']);
|
|
});
|
|
|
|
it('shows only the 기준 pier when nothing else is checked', () => {
|
|
const none = list.map((p) => ({ ...p, checked: false }));
|
|
expect(shownNames(none, 'P2')).toEqual(['P2']);
|
|
});
|
|
});
|
|
|
|
describe('overrideTargets (기준 교각의 수정 값을 받을 교각)', () => {
|
|
it('is the checked piers other than the 기준 pier', () => {
|
|
expect(overrideTargets(list, 'P1')).toEqual(['P2']);
|
|
expect(overrideTargets(list, 'P3')).toEqual(['P1', 'P2']);
|
|
});
|
|
});
|
|
|
|
describe('applyOverrides (기준 교각의 변경 항목만 옮김)', () => {
|
|
const base = loadP1();
|
|
const defaults = base;
|
|
const edited = { ...base, copingWidthMm: base.copingWidthMm + 100 };
|
|
const target = { ...base, copingLengthMm: base.copingLengthMm + 500 };
|
|
|
|
it('copies only the keys the 기준 pier overrides, keeping the target own values', () => {
|
|
const next = applyOverrides({ defaults, input: defaults, draft: edited }, target);
|
|
expect(next.copingWidthMm).toBe(edited.copingWidthMm);
|
|
expect(next.copingLengthMm).toBe(target.copingLengthMm);
|
|
});
|
|
|
|
it('returns the target unchanged when the 기준 pier has no overrides', () => {
|
|
const next = applyOverrides({ defaults, input: defaults, draft: defaults }, target);
|
|
expect(next).toEqual(target);
|
|
});
|
|
});
|