import { describe, it, expect } from 'vitest' import { validPeriodInput, periodInputOptions } from './qaPeriodInput' describe('typed or dropdown natural periods', () => { it('accepts canonical months and real cross-year weeks and rejects incomplete, future or impossible inputs', () => { expect(validPeriodInput('month', '2026-02', '2026-10')).toBe(true) expect(validPeriodInput('week', '2020-W53', '2021-W01')).toBe(true) for (const value of ['', '2026-1', '2026-00', '2026-13', '2027-01', ' 2026-02', '1999-12']) expect(validPeriodInput('month', value, '2026-10')).toBe(false) for (const value of ['', '2021-W53', '2021-W1', '2021-W00', '2026-W44', '2020-W+1', '2020-W53 ']) expect(validPeriodInput('week', value, '2026-W43')).toBe(false) }) it('offers selectable periods across year boundaries without replacing the typed value with an invalid date', () => { expect(periodInputOptions('week', '2021-W01').slice(0, 2)).toEqual(['2021-W01', '2020-W53']) expect(periodInputOptions('month', '2026-01').slice(0, 2)).toEqual(['2026-01', '2025-12']) expect(periodInputOptions('week', '2021-W53')).toEqual([]) }) })