diff --git a/app/components/formatted_date/__snapshots__/index.test.tsx.snap b/app/components/formatted_date/__snapshots__/index.test.tsx.snap new file mode 100644 index 00000000000..af02aa37e05 --- /dev/null +++ b/app/components/formatted_date/__snapshots__/index.test.tsx.snap @@ -0,0 +1,793 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[` should match snapshot for 'bg' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26.10.2024 г. + +`; + +exports[` should match snapshot for 'bg' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 26.10.2024 г., 12:01 ч. + +`; + +exports[` should match snapshot for 'bg' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 26.10, 12:01 ч. + +`; + +exports[` should match snapshot for 'bg' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26.10 + +`; + +exports[` should match snapshot for 'bg' locale and '{"weekday": "long"}' format 1`] = ` + + събота + +`; + +exports[` should match snapshot for 'bg' locale and 'undefined' format 1`] = ` + + 26.10.2024 г. + +`; + +exports[` should match snapshot for 'de' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26.10.2024 + +`; + +exports[` should match snapshot for 'de' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 26. Okt. 2024, 12:01 + +`; + +exports[` should match snapshot for 'de' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 26. Okt., 12:01 + +`; + +exports[` should match snapshot for 'de' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26. Okt. + +`; + +exports[` should match snapshot for 'de' locale and '{"weekday": "long"}' format 1`] = ` + + Samstag + +`; + +exports[` should match snapshot for 'de' locale and 'undefined' format 1`] = ` + + 26.10.2024 + +`; + +exports[` should match snapshot for 'en' locale and '{"dateStyle": "medium"}' format 1`] = ` + + Oct 26, 2024 + +`; + +exports[` should match snapshot for 'en' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + Oct 26, 2024, 12:01 PM + +`; + +exports[` should match snapshot for 'en' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + Oct 26, 12:01 PM + +`; + +exports[` should match snapshot for 'en' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + Oct 26 + +`; + +exports[` should match snapshot for 'en' locale and '{"weekday": "long"}' format 1`] = ` + + Saturday + +`; + +exports[` should match snapshot for 'en' locale and 'undefined' format 1`] = ` + + Oct 26, 2024 + +`; + +exports[` should match snapshot for 'en-AU' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26 Oct 2024 + +`; + +exports[` should match snapshot for 'en-AU' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 26 Oct 2024, 12:01 pm + +`; + +exports[` should match snapshot for 'en-AU' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 26 Oct, 12:01 pm + +`; + +exports[` should match snapshot for 'en-AU' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26 Oct + +`; + +exports[` should match snapshot for 'en-AU' locale and '{"weekday": "long"}' format 1`] = ` + + Saturday + +`; + +exports[` should match snapshot for 'en-AU' locale and 'undefined' format 1`] = ` + + 26 Oct 2024 + +`; + +exports[` should match snapshot for 'es' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26 oct 2024 + +`; + +exports[` should match snapshot for 'es' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 26 oct 2024, 12:01 + +`; + +exports[` should match snapshot for 'es' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 26 oct, 12:01 + +`; + +exports[` should match snapshot for 'es' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26 oct + +`; + +exports[` should match snapshot for 'es' locale and '{"weekday": "long"}' format 1`] = ` + + sábado + +`; + +exports[` should match snapshot for 'es' locale and 'undefined' format 1`] = ` + + 26 oct 2024 + +`; + +exports[` should match snapshot for 'fa' locale and '{"dateStyle": "medium"}' format 1`] = ` + + ۵ آبان ۱۴۰۳ + +`; + +exports[` should match snapshot for 'fa' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + ۵ آبان ۱۴۰۳، ۱۲:۰۱ + +`; + +exports[` should match snapshot for 'fa' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + ۵ آبان، ۱۲:۰۱ + +`; + +exports[` should match snapshot for 'fa' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + ۵ آبان + +`; + +exports[` should match snapshot for 'fa' locale and '{"weekday": "long"}' format 1`] = ` + + شنبه + +`; + +exports[` should match snapshot for 'fa' locale and 'undefined' format 1`] = ` + + ۵ آبان ۱۴۰۳ + +`; + +exports[` should match snapshot for 'fr' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26 oct. 2024 + +`; + +exports[` should match snapshot for 'fr' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 26 oct. 2024, 12:01 + +`; + +exports[` should match snapshot for 'fr' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 26 oct., 12:01 + +`; + +exports[` should match snapshot for 'fr' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26 oct. + +`; + +exports[` should match snapshot for 'fr' locale and '{"weekday": "long"}' format 1`] = ` + + samedi + +`; + +exports[` should match snapshot for 'fr' locale and 'undefined' format 1`] = ` + + 26 oct. 2024 + +`; + +exports[` should match snapshot for 'hu' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 2024. okt. 26. + +`; + +exports[` should match snapshot for 'hu' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 2024. okt. 26. 12:01 + +`; + +exports[` should match snapshot for 'hu' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + okt. 26. 12:01 + +`; + +exports[` should match snapshot for 'hu' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + okt. 26. + +`; + +exports[` should match snapshot for 'hu' locale and '{"weekday": "long"}' format 1`] = ` + + szombat + +`; + +exports[` should match snapshot for 'hu' locale and 'undefined' format 1`] = ` + + 2024. okt. 26. + +`; + +exports[` should match snapshot for 'it' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26 ott 2024 + +`; + +exports[` should match snapshot for 'it' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 26 ott 2024, 12:01 + +`; + +exports[` should match snapshot for 'it' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 26 ott, 12:01 + +`; + +exports[` should match snapshot for 'it' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26 ott + +`; + +exports[` should match snapshot for 'it' locale and '{"weekday": "long"}' format 1`] = ` + + sabato + +`; + +exports[` should match snapshot for 'it' locale and 'undefined' format 1`] = ` + + 26 ott 2024 + +`; + +exports[` should match snapshot for 'ja' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 2024/10/26 + +`; + +exports[` should match snapshot for 'ja' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 2024年10月26日 12:01 + +`; + +exports[` should match snapshot for 'ja' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 10月26日 12:01 + +`; + +exports[` should match snapshot for 'ja' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 10月26日 + +`; + +exports[` should match snapshot for 'ja' locale and '{"weekday": "long"}' format 1`] = ` + + 土曜日 + +`; + +exports[` should match snapshot for 'ja' locale and 'undefined' format 1`] = ` + + 2024/10/26 + +`; + +exports[` should match snapshot for 'ko' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 2024. 10. 26. + +`; + +exports[` should match snapshot for 'ko' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 2024년 10월 26일 오후 12:01 + +`; + +exports[` should match snapshot for 'ko' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 10월 26일 오후 12:01 + +`; + +exports[` should match snapshot for 'ko' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 10월 26일 + +`; + +exports[` should match snapshot for 'ko' locale and '{"weekday": "long"}' format 1`] = ` + + 토요일 + +`; + +exports[` should match snapshot for 'ko' locale and 'undefined' format 1`] = ` + + 2024. 10. 26. + +`; + +exports[` should match snapshot for 'nl' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26 okt 2024 + +`; + +exports[` should match snapshot for 'nl' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 26 okt 2024, 12:01 + +`; + +exports[` should match snapshot for 'nl' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 26 okt, 12:01 + +`; + +exports[` should match snapshot for 'nl' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26 okt + +`; + +exports[` should match snapshot for 'nl' locale and '{"weekday": "long"}' format 1`] = ` + + zaterdag + +`; + +exports[` should match snapshot for 'nl' locale and 'undefined' format 1`] = ` + + 26 okt 2024 + +`; + +exports[` should match snapshot for 'pl' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26 paź 2024 + +`; + +exports[` should match snapshot for 'pl' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 26 paź 2024, 12:01 + +`; + +exports[` should match snapshot for 'pl' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 26 paź, 12:01 + +`; + +exports[` should match snapshot for 'pl' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26 paź + +`; + +exports[` should match snapshot for 'pl' locale and '{"weekday": "long"}' format 1`] = ` + + sobota + +`; + +exports[` should match snapshot for 'pl' locale and 'undefined' format 1`] = ` + + 26 paź 2024 + +`; + +exports[` should match snapshot for 'pt-BR' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26 de out. de 2024 + +`; + +exports[` should match snapshot for 'pt-BR' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 26 de out. de 2024, 12:01 + +`; + +exports[` should match snapshot for 'pt-BR' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 26 de out., 12:01 + +`; + +exports[` should match snapshot for 'pt-BR' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26 de out. + +`; + +exports[` should match snapshot for 'pt-BR' locale and '{"weekday": "long"}' format 1`] = ` + + sábado + +`; + +exports[` should match snapshot for 'pt-BR' locale and 'undefined' format 1`] = ` + + 26 de out. de 2024 + +`; + +exports[` should match snapshot for 'ro' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26 oct. 2024 + +`; + +exports[` should match snapshot for 'ro' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 26 oct. 2024, 12:01 + +`; + +exports[` should match snapshot for 'ro' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 26 oct., 12:01 + +`; + +exports[` should match snapshot for 'ro' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26 oct. + +`; + +exports[` should match snapshot for 'ro' locale and '{"weekday": "long"}' format 1`] = ` + + sâmbătă + +`; + +exports[` should match snapshot for 'ro' locale and 'undefined' format 1`] = ` + + 26 oct. 2024 + +`; + +exports[` should match snapshot for 'ru' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26 окт. 2024 г. + +`; + +exports[` should match snapshot for 'ru' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 26 окт. 2024 г., 12:01 + +`; + +exports[` should match snapshot for 'ru' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 26 окт., 12:01 + +`; + +exports[` should match snapshot for 'ru' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26 окт. + +`; + +exports[` should match snapshot for 'ru' locale and '{"weekday": "long"}' format 1`] = ` + + суббота + +`; + +exports[` should match snapshot for 'ru' locale and 'undefined' format 1`] = ` + + 26 окт. 2024 г. + +`; + +exports[` should match snapshot for 'sv' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26 okt. 2024 + +`; + +exports[` should match snapshot for 'sv' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 26 okt. 2024 12:01 + +`; + +exports[` should match snapshot for 'sv' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 26 okt. 12:01 + +`; + +exports[` should match snapshot for 'sv' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26 okt. + +`; + +exports[` should match snapshot for 'sv' locale and '{"weekday": "long"}' format 1`] = ` + + lördag + +`; + +exports[` should match snapshot for 'sv' locale and 'undefined' format 1`] = ` + + 26 okt. 2024 + +`; + +exports[` should match snapshot for 'tr' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26 Eki 2024 + +`; + +exports[` should match snapshot for 'tr' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 26 Eki 2024 12:01 + +`; + +exports[` should match snapshot for 'tr' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 26 Eki 12:01 + +`; + +exports[` should match snapshot for 'tr' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26 Eki + +`; + +exports[` should match snapshot for 'tr' locale and '{"weekday": "long"}' format 1`] = ` + + Cumartesi + +`; + +exports[` should match snapshot for 'tr' locale and 'undefined' format 1`] = ` + + 26 Eki 2024 + +`; + +exports[` should match snapshot for 'uk' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26 жовт. 2024 р. + +`; + +exports[` should match snapshot for 'uk' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 26 жовт. 2024 р., 12:01 + +`; + +exports[` should match snapshot for 'uk' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 26 жовт., 12:01 + +`; + +exports[` should match snapshot for 'uk' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26 жовт. + +`; + +exports[` should match snapshot for 'uk' locale and '{"weekday": "long"}' format 1`] = ` + + субота + +`; + +exports[` should match snapshot for 'uk' locale and 'undefined' format 1`] = ` + + 26 жовт. 2024 р. + +`; + +exports[` should match snapshot for 'vi' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 26 thg 10, 2024 + +`; + +exports[` should match snapshot for 'vi' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 12:01 26 thg 10, 2024 + +`; + +exports[` should match snapshot for 'vi' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 12:01 26 thg 10 + +`; + +exports[` should match snapshot for 'vi' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 26 thg 10 + +`; + +exports[` should match snapshot for 'vi' locale and '{"weekday": "long"}' format 1`] = ` + + Thứ Bảy + +`; + +exports[` should match snapshot for 'vi' locale and 'undefined' format 1`] = ` + + 26 thg 10, 2024 + +`; + +exports[` should match snapshot for 'zh-CN' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 2024年10月26日 + +`; + +exports[` should match snapshot for 'zh-CN' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 2024年10月26日 12:01 + +`; + +exports[` should match snapshot for 'zh-CN' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 10月26日 12:01 + +`; + +exports[` should match snapshot for 'zh-CN' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 10月26日 + +`; + +exports[` should match snapshot for 'zh-CN' locale and '{"weekday": "long"}' format 1`] = ` + + 星期六 + +`; + +exports[` should match snapshot for 'zh-CN' locale and 'undefined' format 1`] = ` + + 2024年10月26日 + +`; + +exports[` should match snapshot for 'zh-TW' locale and '{"dateStyle": "medium"}' format 1`] = ` + + 2024年10月26日 + +`; + +exports[` should match snapshot for 'zh-TW' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short", "year": "numeric"}' format 1`] = ` + + 2024年10月26日 下午12:01 + +`; + +exports[` should match snapshot for 'zh-TW' locale and '{"day": "numeric", "hour": "numeric", "minute": "numeric", "month": "short"}' format 1`] = ` + + 10月26日 下午12:01 + +`; + +exports[` should match snapshot for 'zh-TW' locale and '{"day": "numeric", "month": "short"}' format 1`] = ` + + 10月26日 + +`; + +exports[` should match snapshot for 'zh-TW' locale and '{"weekday": "long"}' format 1`] = ` + + 星期六 + +`; + +exports[` should match snapshot for 'zh-TW' locale and 'undefined' format 1`] = ` + + 2024年10月26日 + +`; diff --git a/app/components/formatted_date/index.test.tsx b/app/components/formatted_date/index.test.tsx new file mode 100644 index 00000000000..65dcf69498c --- /dev/null +++ b/app/components/formatted_date/index.test.tsx @@ -0,0 +1,48 @@ +// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. +// See LICENSE.txt for license information. + +import React from 'react'; + +import {renderWithIntl} from '@test/intl-test-helper'; + +import locales from '../../i18n/languages'; + +import FormattedDate, {type FormattedDateFormat} from './index'; + +const DATE = new Date('2024-10-26T10:01:04.653Z'); +const FORMATS = [ + undefined, + {weekday: 'long'}, + {dateStyle: 'medium'}, + {month: 'short', day: 'numeric'}, + { + month: 'short', + day: 'numeric', + hour: 'numeric', + minute: 'numeric', + }, + { + year: 'numeric', + month: 'short', + day: 'numeric', + hour: 'numeric', + minute: 'numeric', + }, +] satisfies Array; + +const TEST_MATRIX = Object.keys(locales). + map((locale) => FORMATS.map<[string, FormattedDateFormat | undefined]>((format) => [locale, format])). + flat(1); + +describe('', () => { + it.each(TEST_MATRIX)("should match snapshot for '%s' locale and '%p' format", (locale, format) => { + const wrapper = renderWithIntl( + , + {locale}, + ); + expect(wrapper.toJSON()).toMatchSnapshot(); + }); +});