import { describe, expect, it } from 'vitest'; import { parseDrawingRows } from '../src/core/drawing-import'; const header = ['No', '열', 'EL.X (m)', 'h1 (mm)', 'h2 (mm)']; describe('도면 불러오기 (승인 2026-10-23)', () => { it('reads No, EL.X, h1, h2 from a sheet with a header and ignores other columns', () => { const rows = [['도면 받침', '', '', '', ''], header, [1, '전열', 43.625, 164, 50], [2, '전열', 43.697, 164, 50]]; const r = parseDrawingRows(rows); expect(r.errors).toEqual([]); expect(r.rows).toEqual([ { no: 1, elx: 43.625, h1: 164, h2: 50 }, { no: 2, elx: 43.697, h1: 164, h2: 50 }, ]); }); it('accepts the header spelled as "EL. X" and in a different order', () => { const rows = [['h2', 'No', 'h1', 'EL. X'], [50, 1, 164, 43.625]]; const r = parseDrawingRows(rows); expect(r.errors).toEqual([]); expect(r.rows[0]).toEqual({ no: 1, elx: 43.625, h1: 164, h2: 50 }); }); it('reports a missing header, a duplicate No, and an EL.X given in mm', () => { expect(parseDrawingRows([['x', 'y']]).errors[0]).toContain('머리글'); const dup = parseDrawingRows([header, [1, '', 43.6, 164, 50], [1, '', 43.7, 164, 50]]); expect(dup.errors.some((e) => e.includes('중복'))).toBe(true); const mm = parseDrawingRows([header, [1, '', 43625, 164, 50]]); expect(mm.errors.some((e) => e.includes('m 단위'))).toBe(true); expect(mm.rows).toEqual([]); }); });