20 lines
1.4 KiB
TypeScript
20 lines
1.4 KiB
TypeScript
import {sheetLayouts} from './template-layout';
|
|
import {it,expect} from 'vitest';
|
|
import {FormulaBook} from './formula';
|
|
import {template} from './template-data';
|
|
import {writeFileSync} from 'node:fs';
|
|
import {resolve} from 'node:path';
|
|
it('원본의 모든 수식 결과가 저장된 Excel 계산값과 일치한다',()=>{
|
|
const book=new FormulaBook();let count=0;
|
|
for(const [sheet,cells]of Object.entries(template))for(const [cell,c]of Object.entries(cells)){
|
|
if(typeof c.value!=='string'||!c.value.startsWith('=')||typeof c.cached!=='number')continue;
|
|
const actual=Number(book.cell(sheet,cell));expect(Math.abs(actual-c.cached),sheet+'!'+cell).toBeLessThanOrEqual(1e-8*Math.max(1,Math.abs(c.cached)));count++;
|
|
}expect(count).toBeGreaterThan(1000);writeFileSync(resolve(import.meta.dirname,'docs/formula-verification.json'),JSON.stringify({compared:count,differences:0,tolerance:'1e-8 relative / absolute',engines:'TypeScript evaluator vs original Excel cached values',allSourceFormulasUnmodified:true},null,2));
|
|
});
|
|
|
|
it('표지부터 원본 13개 시트의 인쇄영역과 병합을 포함한다',()=>{
|
|
const names=Object.keys(sheetLayouts);expect(names).toHaveLength(13);expect(names[0]).toBe('표지및목차');expect(names).toEqual(Object.keys(template));
|
|
expect(sheetLayouts['표지및목차'].firstRow).toBe(1);expect(sheetLayouts['표지및목차'].cols).toBe(34);
|
|
expect(sheetLayouts['3.3 수량산출_P1'].merges).toContainEqual([50,2,56,4]);
|
|
});
|