import { describe, expect, it } from 'vitest' import { clampJalaliDateParts, isAllowedBirthDate, isoDateToJalaliParts, jalaliPartsToIsoDate } from '@/lib/birthDate' describe('birth date helpers', () => { it('converts Jalali wheel values to a Gregorian date-only string', () => { expect(jalaliPartsToIsoDate({ day: '1', month: '1', year: '1370' })).toBe('1991-03-21') expect(jalaliPartsToIsoDate({ day: '1', month: '1', year: '1330' })).toBe('1951-03-22') expect(jalaliPartsToIsoDate({ day: '30', month: '12', year: '1395' })).toBe('2017-03-20') }) it('clamps Esfand days to the selected Jalali year length', () => { expect(clampJalaliDateParts({ day: '31', month: '12', year: '1395' })).toEqual({ day: '30', month: '12', year: '1395', }) expect(clampJalaliDateParts({ day: '31', month: '7', year: '1370' })).toEqual({ day: '30', month: '7', year: '1370', }) }) it('accepts only ISO dates whose Jalali year is 1330–1395', () => { expect(isAllowedBirthDate('1991-03-21')).toBe(true) expect(isoDateToJalaliParts('1991-03-21')).toEqual({ day: '1', month: '1', year: '1370' }) expect(isAllowedBirthDate('1951-03-21')).toBe(false) expect(isAllowedBirthDate('2018-01-01')).toBe(false) expect(isAllowedBirthDate('1991-03-21T00:00:00.000Z')).toBe(false) }) })