import { getDateStringFromISO } from './index' describe('datetime - getDateStringFromISO', () => { it.each([ ['en-US', 'America/New_York', '2021-01-01T00:00:00.000-05:00'], ['es-UY', 'America/Montevideo', '2021-01-01T00:00:00.000-03:00'], ['pt-BR', 'America/Sao_Paulo', '2021-01-01T00:00:00.000-03:00'], ['en-GB', 'Europe/London', '2021-01-01T00:00:00.000+00:00'], ['fr-FR', 'Europe/Paris', '2021-01-01T00:00:00.000+01:00'], ['ka-GE', 'Asia/Tbilisi', '2021-01-01T00:00:00.000+04:00'], ['hi-IN', 'Asia/Kolkata', '2021-01-01T00:00:00.000+05:30'], ])( 'daylightSavingDateTime, should return a date string in the format "YYYY-MM-DD", locale=%s, timezone=%s', (locale, timezone, dateString) => { const result = getDateStringFromISO(dateString, { locale, timezone }) expect(result).toBe('2021-01-01') } ) it.each([ ['en-US', 'America/New_York', '2021-07-01T00:00:00.000-04:00'], ['es-UY', 'America/Montevideo', '2021-07-01T00:00:00.000-03:00'], ['pt-BR', 'America/Sao_Paulo', '2021-07-01T00:00:00.000-03:00'], ['en-GB', 'Europe/London', '2021-07-01T00:00:00.000+01:00'], ['fr-FR', 'Europe/Paris', '2021-07-01T00:00:00.000+02:00'], ['ka-GE', 'Asia/Tbilisi', '2021-07-01T00:00:00.000+04:00'], ['hi-IN', 'Asia/Kolkata', '2021-07-01T00:00:00.000+05:30'], ])( 'standardDateTime, should return a date string in the format "YYYY-MM-DD", locale=%s, timezone=%s', (locale, timezone, dateString) => { const result = getDateStringFromISO(dateString, { locale, timezone }) expect(result).toBe('2021-07-01') } ) it('should throw an error if the date is invalid', () => expect(() => getDateStringFromISO('invalid')).toThrow( 'Invalid date string: invalid' )) })