Files
Pier_v1/tests/coping-settings.test.ts
T
ypshimandClaude Haiku 5.5 9c93a6aa01 feat(rebar): 코핑 배근 입력 12개 · CP01·CP02 검사 · 적용 버튼
- core/rebar/coping-settings.ts: 입력 정의, 기본값(코핑철근.md), 범위(코핑_입력범위_제안.md), 검사 함수
- 다리 수는 4·6·8 목록으로 두고 홀수는 CP02로 막음
- 값은 적용 버튼을 누를 때만 draft에 쓰고 다시 생성 (범위 밖이면 반영하지 않음)
- PierInput.copingRebar, 모델 copingRebar, 변경 추적 키 추가

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-26 15:26:20 +09:00

36 lines
1.6 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { COPING_REBAR_RANGES, copingSettingsIssues, DEFAULT_COPING_REBAR } from '../src/core/rebar/coping-settings';
describe('코핑 배근 입력 범위 (승인 2026-10-26)', () => {
it('the defaults are inside every range and raise no issue', () => {
expect(copingSettingsIssues(DEFAULT_COPING_REBAR)).toEqual([]);
for (const [key, [lo, hi]] of Object.entries(COPING_REBAR_RANGES)) {
const v = DEFAULT_COPING_REBAR[key as keyof typeof DEFAULT_COPING_REBAR];
expect(v >= lo && v <= hi, key).toBe(true);
}
});
it('a value at either end of its range is accepted', () => {
const lo = { ...DEFAULT_COPING_REBAR, cover: 80, shearLegs: 4 };
const hi = { ...DEFAULT_COPING_REBAR, cover: 150, shearLegs: 8 };
expect(copingSettingsIssues(lo)).toEqual([]);
expect(copingSettingsIssues(hi)).toEqual([]);
});
it('a value outside its range gives CP01 on that key', () => {
const issues = copingSettingsIssues({ ...DEFAULT_COPING_REBAR, cover: 151 });
expect(issues).toHaveLength(1);
expect(issues[0]).toMatchObject({ code: 'CP01', key: 'cover' });
});
it('a non-finite value gives CP01', () => {
const issues = copingSettingsIssues({ ...DEFAULT_COPING_REBAR, spacingS: Number.NaN });
expect(issues).toEqual([expect.objectContaining({ code: 'CP01', key: 'spacingS' })]);
});
it('an odd shear leg count gives CP02 (and no CP01 because 5 is in range)', () => {
const issues = copingSettingsIssues({ ...DEFAULT_COPING_REBAR, shearLegs: 5 });
expect(issues).toEqual([expect.objectContaining({ code: 'CP02', key: 'shearLegs' })]);
});
});