Files
Pier_v1/tests/column-rebar-settings.test.ts
T
CopilotandCopilot 06e1b97a62
ITAM Code Check / build-and-config-check (push) Failing after 37s
ITAM Docker Build Check / docker-build-check (push) Failing after 1m0s
교각 프로그램 초기 버전
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-02 15:55:01 +09:00

45 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { describe, expect, it } from 'vitest';
import { buildPier } from '../src/core/geometry';
import { columnInputFor, columnRebar } from '../src/core/rebar/column';
import { COLUMN_REBAR_RANGES, columnSettingsIssues, DEFAULT_COLUMN_REBAR } from '../src/core/rebar/column-settings';
import { rebarSummary } from '../src/core/rebar/summary';
import { loadP1 } from './helpers';
describe('기둥 배근 입력 (승인 2026-10-26, 시안 ③ 기둥)', () => {
it('the defaults are inside every range and raise no issue', () => {
expect(columnSettingsIssues(DEFAULT_COLUMN_REBAR)).toEqual([]);
for (const [key, [lo, hi]] of Object.entries(COLUMN_REBAR_RANGES)) {
const v = DEFAULT_COLUMN_REBAR[key as keyof typeof DEFAULT_COLUMN_REBAR];
expect(v >= lo && v <= hi, key).toBe(true);
}
});
it('a value outside its range gives CL01 on that key; an odd n_div gives CL02', () => {
expect(columnSettingsIssues({ ...DEFAULT_COLUMN_REBAR, c: 151 })).toEqual([expect.objectContaining({ code: 'CL01', key: 'c' })]);
expect(columnSettingsIssues({ ...DEFAULT_COLUMN_REBAR, nDiv: 45 })).toEqual([expect.objectContaining({ code: 'CL02', key: 'nDiv' })]);
});
it('P1 defaults: P1 원주 46등분, P3 간격 300 · 기본값 근거', () => {
const rows = rebarSummary(buildPier(loadP1())).rows;
const p1 = rows.find((r) => r.name === 'P1')!;
expect([p1.spacing, p1.basis]).toEqual(['원주 46등분', 'default']);
const p3 = rows.find((r) => r.name === 'P3')!;
expect([p3.spacing, p3.actual, p3.basis]).toEqual(['300', '300', 'default']);
});
it('changed inputs reach the table (간격·근거·비고) and the column input', () => {
const m = buildPier({ ...loadP1(), columnRebar: { ctcP3: 320, nDiv: 40 } });
expect(columnInputFor(m).ctcP3).toBe(320);
expect(columnInputFor(m).nDiv).toBe(40);
const rows = rebarSummary(m).rows;
const p3 = rows.find((r) => r.name === 'P3')!;
expect([p3.spacing, p3.basis]).toEqual(['320', 'input']);
expect(p3.note).toContain('@320');
const p1 = rows.find((r) => r.name === 'P1')!;
expect([p1.spacing, p1.basis]).toEqual(['원주 40등분', 'input']);
// mainP1 = n_div × (couplers + 1): 40 bars per level.
const col = columnRebar(columnInputFor(m));
expect(col.mainP1).toBe(40 * (col.couplerP1.length + 1));
});
});