import { absoluteDatetime } from './index' describe('formatting - absoluteDatetime', () => { const daylightSavingDateTime = '2021-02-28T00:00:00.000Z' // UTC const standardDateTime = '2021-07-31T00:00:00.000Z' // UTC it.each([ ['America/Phoenix', 'en-US', '2/27/2021 5:00 PM'], ['America/Chicago', 'en-US', '2/27/2021 6:00 PM'], ['America/New_York', 'en-US', '2/27/2021 7:00 PM'], ['America/Montevideo', 'es-UY', '27/2/2021 9:00 p. m.'], ['America/Sao_Paulo', 'pt-BR', '27/02/2021 21:00'], ['UTC', 'en-US', '2/28/2021 12:00 AM'], ['UTC', 'en-GB', '28/02/2021 00:00'], ['Europe/London', 'en-GB', '28/02/2021 00:00'], ['Europe/Paris', 'fr-FR', '28/02/2021 01:00'], ['Asia/Tbilisi', 'ka-GE', '28.2.2021 04:00'], ['Asia/Kolkata', 'hi-IN', '28/2/2021 5:30 am'], ['Australia/Melbourne', 'en-AU', '28/02/2021 11:00 am'], ])( 'daylightSavingDateTime - returns a string formatted for the TZ and Locale (TZ: %s, Locale: %s)', (timezone, locale, localisedResult) => { const result = absoluteDatetime(daylightSavingDateTime, { timezone, locale, }) expect(result).toEqual(localisedResult) } ) it.each([ ['America/Phoenix', 'en-US', '7/30/2021 5:00 PM'], ['America/Chicago', 'en-US', '7/30/2021 7:00 PM'], ['America/New_York', 'en-US', '7/30/2021 8:00 PM'], ['America/Montevideo', 'es-UY', '30/7/2021 9:00 p. m.'], ['America/Sao_Paulo', 'pt-BR', '30/07/2021 21:00'], ['UTC', 'en-US', '7/31/2021 12:00 AM'], ['UTC', 'en-GB', '31/07/2021 00:00'], ['Europe/London', 'en-GB', '31/07/2021 01:00'], ['Europe/Paris', 'fr-FR', '31/07/2021 02:00'], ['Asia/Tbilisi', 'ka-GE', '31.7.2021 04:00'], ['Asia/Kolkata', 'hi-IN', '31/7/2021 5:30 am'], ['Australia/Melbourne', 'en-AU', '31/07/2021 10:00 am'], ])( 'standardDateTime - returns a string formatted for the TZ and Locale (TZ: %s, Locale: %s)', (timezone, locale, localisedResult) => { const result = absoluteDatetime(standardDateTime, { timezone, locale, }) expect(result).toEqual(localisedResult) } ) })