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' })]); }); });