修复:清理导入历史失败提示并识别旧文件年份
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import {readFileSync} from 'node:fs';
|
||||
import ts from 'typescript';
|
||||
const source=ts.transpileModule(readFileSync(new URL('../src/sourceWorkbookDetection.ts',import.meta.url),'utf8'),{compilerOptions:{target:ts.ScriptTarget.ES2022,module:ts.ModuleKind.ESNext}}).outputText.replace(/^import .*;\n/gm,'').replace(/export /g,'');
|
||||
const {sourceFilenamePeriod:period,sourceBatchYear:year}=new Function(source+';return {sourceFilenamePeriod,sourceBatchYear};')();
|
||||
test('actual historical quality workbook names identify 2025 without confusing split-date ranges',()=>{
|
||||
assert.deepEqual(period('1月亮片质量数据统计表25.1.xlsx'),{year:2025,month:1});
|
||||
assert.deepEqual(period('2月黑片质量数据统计表25.2上.xlsx'),{year:2025,month:2});
|
||||
assert.deepEqual(period('7月亮片质量数据统计表25.7.29-7.31.xlsx'),{year:2025,month:7});
|
||||
assert.deepEqual(period('3月黑片质量数据统计表3.16~3.31.xlsx'),{year:undefined,month:3});
|
||||
assert.deepEqual(period('2025年12月黑片.xlsx'),{year:2025,month:12});
|
||||
assert.deepEqual(period('6月质量数据统计表25.5.xlsx'),{year:undefined,month:6});
|
||||
});
|
||||
test('a consistent batch year also applies to same-batch files without a year; mixed explicit years keep individual identities',()=>{
|
||||
assert.equal(year(['1月亮片质量数据统计表25.1.xlsx','12月黑片质量数据统计表12月1日-12月31日.xlsx'],2026),2025);
|
||||
assert.equal(year(['2025年1月黑片.xlsx','2026年1月黑片.xlsx'],2026),2026);
|
||||
assert.equal(year(['3月黑片质量数据统计表3.16~3.31.xlsx'],2026),2026);
|
||||
assert.equal(period('2025年1月黑片.xlsx').year,2025);
|
||||
});
|
||||
Reference in New Issue
Block a user