1
0

test: Added xlsx parsing tests
Remote Deploy / deploy (push) Successful in 1m25s

This commit is contained in:
2026-06-04 11:52:41 +02:00
parent 1c6023beab
commit e94c43ca6e
9 changed files with 1724 additions and 367 deletions
+4 -5
View File
@@ -39,7 +39,7 @@ interface ResolvedDay {
/**
* Read theme colors from the workbook
*/
async function getThemeColors(filePath: string): Promise<ThemeColors | null> {
export async function getThemeColors(filePath: string): Promise<ThemeColors | null> {
const data = fs.readFileSync(filePath);
const zip = await JSZip.loadAsync(data);
@@ -164,10 +164,9 @@ export default async function parseV3(workbook: Workbook, downloadedFilePath: st
// ────────────────────────────────────────────────────────────
//
function getUpcomingSheets(workbook: ExcelJS.Workbook): ResolvedDay[] {
export function getUpcomingSheets(workbook: ExcelJS.Workbook, today: Date = new Date()): ResolvedDay[] {
const dateRegex = /^(pondělí|úterý|středa|čtvrtek|pátek|po|út|ut|st|čt|ct|pa|pá)\s+(\d{1,2})\.+\s*(\d{1,2})\.+\s*(\d{4}|\d{2})/i;
const today = new Date();
const todayMidnight = new Date(today.getFullYear(), today.getMonth(), today.getDate());
const result: ResolvedDay[] = [];
@@ -190,7 +189,7 @@ function getUpcomingSheets(workbook: ExcelJS.Workbook): ResolvedDay[] {
return result;
}
function groupSheetsByDate(items: ResolvedDay[]) {
export function groupSheetsByDate(items: ResolvedDay[]) {
const map: Record<string, Worksheet[]> = {};
for (const item of items) {
@@ -214,7 +213,7 @@ function groupSheetsByDate(items: ResolvedDay[]) {
// ────────────────────────────────────────────────────────────
//
function extractDaySchedule(sheet: Worksheet, teacherMap: Record<string, string>, themeColors: ThemeColors | null, flags: Flag[]) {
export function extractDaySchedule(sheet: Worksheet, teacherMap: Record<string, string>, themeColors: ThemeColors | null, flags: Flag[]) {
return {
changes: extractClassChanges(sheet, themeColors, flags),
absence: extractAbsence(sheet, teacherMap),