Files
Pier_v1/tests/template.test.ts
T

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([]);
});
});