import { describe, it, expect } from 'vitest'; import { reportDayToDate, dateToReportDay, feedOrWeightDayToReportDay, formatLocalDate, } from '../reportDay.ts'; /** Same instant PdfReportHeader tests use: 22 Mei 2026 00:00 WIB. */ const START = '2026-05-21T17:00:00.000Z'; describe('reportDayToDate', () => { it('maps day 0 to the cycle start date', () => { const date = reportDayToDate(START, 0); expect(formatLocalDate(date)).toBe('2026-05-22'); }); it('maps day 1 to the day after cycle start', () => { const date = reportDayToDate(START, 1); expect(formatLocalDate(date)).toBe('2026-05-23'); }); }); describe('dateToReportDay', () => { it('maps cycle start calendar date to report day 0', () => { expect(dateToReportDay(START, reportDayToDate(START, 0))).toBe(0); }); }); describe('feedOrWeightDayToReportDay', () => { it('maps 1-based feed day 1 on cycle start to report day 0', () => { expect(feedOrWeightDayToReportDay(1)).toBe(0); const start = reportDayToDate(START, 0); expect(dateToReportDay(START, start)).toBe(0); }); });