- parseWorkbook returns a report per sheet (table counts, issues, ok) - sheets with E-level issues cannot be selected (spec section 2.3) - pier input carries its source sheet name Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
52 lines
2.1 KiB
TypeScript
52 lines
2.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { parseWorkbook } from '../src/core/parseWorkbook';
|
|
import { loadP1, loadWorkbook } from './helpers';
|
|
|
|
describe('parseWorkbook (P1 sheet intent.PR)', () => {
|
|
it('finds exactly one pier P1 with the input values of the sheet', () => {
|
|
const { piers, issues } = parseWorkbook(loadWorkbook());
|
|
expect(issues).toEqual([]);
|
|
expect(piers.map((p) => p.name)).toEqual(['P1']);
|
|
const p1 = loadP1();
|
|
expect(p1.type).toBe('T형');
|
|
expect(p1.foundationType).toBe('말뚝기초');
|
|
expect(p1.copingTopEl).toBeCloseTo(43.411, 6);
|
|
expect(p1.footingBottomEl).toBeCloseTo(26.208, 6);
|
|
expect(p1.groundEl).toBeCloseTo(28.931, 6);
|
|
expect(p1.pileLengthMm).toBe(24000);
|
|
expect(p1.copingWidthMm).toBe(3100);
|
|
expect(p1.copingLengthMm).toBe(12000);
|
|
expect(p1.columnCount).toBe(1);
|
|
});
|
|
|
|
it('reads 4 IP points and 10 bearings (5 front, 5 back)', () => {
|
|
const p1 = loadP1();
|
|
expect(p1.ips.map((p) => p.name)).toEqual(['IP1', 'IP2', 'IP3', 'IP4']);
|
|
expect(p1.bearings).toHaveLength(10);
|
|
expect(p1.bearings.filter((b) => b.row === '전열')).toHaveLength(5);
|
|
expect(p1.bearings.filter((b) => b.row === '후열')).toHaveLength(5);
|
|
});
|
|
|
|
it('converts the bearing azimuth strings to decimal degrees', () => {
|
|
const p1 = loadP1();
|
|
expect(p1.bearings[0].azimuthDeg).toBeCloseTo(75.9489, 4);
|
|
});
|
|
});
|
|
|
|
describe('sheet report (spec §2.3)', () => {
|
|
it('marks the P1 sheet as selectable and counts its tables', () => {
|
|
const { sheets } = parseWorkbook(loadWorkbook());
|
|
expect(sheets).toHaveLength(1);
|
|
expect(sheets[0]).toMatchObject({ name: 'intent.PR', ok: true, piers: 1, tables: { pier: 1, ip: 1, bearing: 1 } });
|
|
});
|
|
|
|
it('marks a sheet with a bad azimuth (E03) as not selectable and drops its pier', () => {
|
|
const wb = loadWorkbook();
|
|
wb.Sheets['intent.PR']['F32'].v = '75.9';
|
|
const { piers, sheets, issues } = parseWorkbook(wb);
|
|
expect(issues.map((i) => i.code)).toContain('E03');
|
|
expect(sheets[0].ok).toBe(false);
|
|
expect(piers).toHaveLength(0);
|
|
});
|
|
});
|