import { describe, expect, it } from 'vitest'; import { berlinDateKey, buildCalendarDays, formatMonthLabel, normalizeMonthKey, shiftMonth } from './calendar.js'; describe('show calendar', () => { it('groups UTC instants by their Berlin civil date', () => { expect(berlinDateKey('2026-09-30T22:30:00.000Z')).toBe('2026-10-01'); expect(berlinDateKey('2026-12-31T23:30:00.000Z')).toBe('2027-01-01'); }); it('builds a Monday-first six-week month without dropping boundary days', () => { const days = buildCalendarDays('2026-10', '2026-10-24'); expect(days).toHaveLength(42); expect(days[0]).toMatchObject({ date: '2026-09-28', inSelectedMonth: false }); expect(days.find((day) => day.date === '2026-10-24')?.isToday).toBe(true); expect(days.at(-1)?.date).toBe('2026-11-08'); }); it('moves across year boundaries and validates month keys', () => { expect(shiftMonth('2026-12', 1)).toBe('2027-01'); expect(shiftMonth('2026-01', -1)).toBe('2025-12'); expect(normalizeMonthKey('2026-13', '2026-10')).toBe('2026-10'); expect(normalizeMonthKey('2026-02', '2026-10')).toBe('2026-02'); expect(formatMonthLabel('2026-10')).toBe('Oktober 2026'); }); });