import { describe, expect, it } from 'vitest'; import { SOLPLATE_RULE_DEFAULT, solplateCenterT, solplatePlan, solplateRuleIssues } from '../src/core/solplate-rule'; describe('솔플레이트 규칙 (C안, 2026-11-03)', () => { it('default 211 · 1000 × 1100 · −0.5 %: T = 25, T1 = 27.5, T2 = 22.5, h3 = 211 − 25 = 186', () => { const p = solplatePlan(SOLPLATE_RULE_DEFAULT); expect(p.T).toBe(25); expect(p.T1).toBeCloseTo(27.5, 9); expect(p.T2).toBeCloseTo(22.5, 9); expect(p.h3).toBe(186); expect(p.L).toBe(1000); expect(p.W).toBe(1100); }); it('the centre thickness is the smallest whole mm that keeps T2 at 22 mm or more', () => { for (const [L, S] of [[1000, -0.5], [1100, -0.5], [1000, -2], [800, -1.91], [1200, -3]] as const) { const T = solplateCenterT(L, S); expect(T - (L * Math.abs(S)) / 200).toBeGreaterThanOrEqual(22); expect(solplateCenterT(L, S) - 1 - (L * Math.abs(S)) / 200).toBeLessThan(22); } }); it('T1 + T2 = 2T for any rule', () => { const p = solplatePlan({ heightMm: 220, lengthMm: 900, widthMm: 800, slopePct: -1.2 }); expect(p.T1 + p.T2).toBeCloseTo(2 * p.T, 9); }); it('the default rule has no input issues', () => { expect(solplateRuleIssues(SOLPLATE_RULE_DEFAULT)).toEqual([]); }); it('reports a bearing height that does not exceed the solplate centre thickness', () => { expect(solplateRuleIssues({ ...SOLPLATE_RULE_DEFAULT, heightMm: 25 })).toHaveLength(1); }); it('reports non-positive plan sizes and a non-numeric slope', () => { expect(solplateRuleIssues({ ...SOLPLATE_RULE_DEFAULT, lengthMm: 0 }).length).toBeGreaterThan(0); expect(solplateRuleIssues({ ...SOLPLATE_RULE_DEFAULT, widthMm: -1 }).length).toBeGreaterThan(0); expect(solplateRuleIssues({ ...SOLPLATE_RULE_DEFAULT, slopePct: NaN }).length).toBeGreaterThan(0); }); });