import * as XLSX from 'xlsx'; import { describe, expect, it } from 'vitest'; import { readProjectInfo } from '../src/core/project-info'; import { loadInputWorkbook } from './helpers'; const book = (sheets: Record) => { const wb = XLSX.utils.book_new(); for (const [name, rows] of Object.entries(sheets)) XLSX.utils.book_append_sheet(wb, XLSX.utils.aoa_to_sheet(rows), name); return wb; }; describe('프로젝트명 · 교량명 (엑셀 입력)', () => { it("the '형상정보' form: B1 '프로젝트명:' → C1, B2 '교량명:' → C2 (운곡교AA · 완도·광주 데이터 양식)", () => { const wb = book({ 형상정보: [[null, '프로젝트명:', '고속국도 제25호선 강진~광주간 건설공사 제5공구'], [null, '교량명:', '운곡교'], [null, '교대명', '형식']], IP: [['교각명']] }); expect(readProjectInfo(wb)).toEqual({ projectName: '고속국도 제25호선 강진~광주간 건설공사 제5공구', bridgeName: '운곡교', source: '형상정보!C1 · 형상정보!C2' }); }); it('the value may follow the colon in the same cell, or sit a few columns to the right, on any sheet', () => { const wb = book({ 표지: [['교량명 : 운곡교'], [], ['프로젝트 명', null, null, '과업 A']] }); expect(readProjectInfo(wb)).toMatchObject({ projectName: '과업 A', bridgeName: '운곡교' }); }); it('an empty form row or a neighbouring label is not taken as the value', () => { expect(readProjectInfo(book({ 형상정보: [['프로젝트명:', '교량명:']] }))).toEqual({}); }); it('the sample workbook (교각 · IP · 받침) has no names: nothing is read', () => { expect(readProjectInfo(loadInputWorkbook())).toEqual({}); }); });