Files
Pier_v1/tests/template.test.ts
T
ypshimandClaude Haiku 5.5 6319cccb8e feat(import): input template download with three sheets (spec 2.3 step 4)
- buildTemplateWorkbook: 교각 · IP · 받침 sheets with the headers the parser
  reads; value cells left empty so no blank-name rows raise E05
- dialog button 입력 템플릿 다운로드 (.xlsx)
- tests: sheet order, parser recognition, write-and-read round trip

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-21 18:14:33 +09:00

31 lines
1.2 KiB
TypeScript

import * as XLSX from 'xlsx';
import { describe, expect, it } from 'vitest';
import { buildTemplateWorkbook } from '../src/core/template';
import { parseWorkbook } from '../src/core/parseWorkbook';
describe('input template (명세 §2.3 ④)', () => {
const wb = buildTemplateWorkbook();
it('has the three sheets 교각, IP, 받침 in that order', () => {
expect(wb.SheetNames).toEqual(['교각', 'IP', '받침']);
});
it('is recognised by the parser: each sheet has its table and no errors', () => {
const { piers, issues, sheets } = parseWorkbook(wb);
expect(piers).toEqual([]);
expect(issues).toEqual([]);
expect(sheets.map((s) => [s.name, s.tables])).toEqual([
['교각', { pier: 1, ip: 0, bearing: 0 }],
['IP', { pier: 0, ip: 1, bearing: 0 }],
['받침', { pier: 0, ip: 0, bearing: 1 }],
]);
});
it('round-trips through a file: written and re-read the same way', () => {
const bytes = XLSX.write(wb, { type: 'array', bookType: 'xlsx' }) as ArrayBuffer;
const back = XLSX.read(new Uint8Array(bytes), { type: 'array' });
expect(back.SheetNames).toEqual(['교각', 'IP', '받침']);
expect(parseWorkbook(back).issues).toEqual([]);
});
});