25 lines
931 B
TypeScript
25 lines
931 B
TypeScript
import {
|
|
extractMonthFromExcelFilename,
|
|
formatMonthRange,
|
|
isSalaryMonth,
|
|
} from "../src/utils/payrollMonth";
|
|
|
|
const detected = extractMonthFromExcelFilename("宁波兆安流体科技有限公司_月度汇总_20260501-20260531.xlsx");
|
|
assertEqual(detected?.month || "", "2026-05");
|
|
assertEqual(detected?.rangeLabel || "", "2026/05/01 至 2026/05/31");
|
|
|
|
const dashed = extractMonthFromExcelFilename("考勤汇总_2026-06.xlsx");
|
|
assertEqual(dashed?.month || "", "2026-06");
|
|
|
|
assertEqual(formatMonthRange("2026-05"), "2026/05/01 至 2026/05/31");
|
|
assertEqual(formatMonthRange(""), "请选择核算月份");
|
|
assertEqual(String(isSalaryMonth("2026-05")), "true");
|
|
assertEqual(String(isSalaryMonth("")), "false");
|
|
assertEqual(String(isSalaryMonth("2026-13")), "false");
|
|
|
|
function assertEqual(actual: string, expected: string): void {
|
|
if (actual !== expected) {
|
|
throw new Error(`期望 ${expected},实际 ${actual}`);
|
|
}
|
|
}
|