Skip to content

Commit bc58136

Browse files
added more tests
1 parent 89a0d0c commit bc58136

File tree

1 file changed

+48
-18
lines changed

1 file changed

+48
-18
lines changed

test/locale/be.test.js

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,44 @@ it('Belarusian locale relative time in past and future without suffix', () => {
6262
const cases = [
6363
[1, 's', 'некалькі секунд'],
6464
[-1, 's', 'некалькі секунд'],
65+
6566
[1, 'm', 'хвіліна'],
6667
[-1, 'm', 'хвіліна'],
6768
[1, 'h', 'гадзіна'],
6869
[-1, 'h', 'гадзіна'],
70+
71+
// Test all plural forms for days
6972
[1, 'd', 'дзень'],
70-
[-1, 'd', 'дзень'],
73+
[21, 'd', '21 дзень'],
74+
[31, 'd', 'месяц'],
75+
// 2-4 form
7176
[2, 'd', '2 дні'],
72-
[-2, 'd', '2 дні'],
73-
[10, 'd', '10 дзён'],
74-
[-10, 'd', '10 дзён'],
75-
[6, 'm', '6 хвілін'],
76-
[-6, 'm', '6 хвілін'],
77-
[5, 'h', '5 гадзін'],
78-
[-5, 'h', '5 гадзін'],
79-
[3, 'M', '3 месяцы'],
80-
[-3, 'M', '3 месяцы'],
81-
[4, 'y', '4 гады'],
82-
[-4, 'y', '4 гады']
77+
[3, 'd', '3 дні'],
78+
[4, 'd', '4 дні'],
79+
// 5-20 and other cases
80+
[5, 'd', '5 дзён'],
81+
[6, 'd', '6 дзён'],
82+
// 11-14 special case
83+
[11, 'd', '11 дзён'],
84+
[12, 'd', '12 дзён'],
85+
[13, 'd', '13 дзён'],
86+
[14, 'd', '14 дзён'],
87+
// 22-24
88+
[22, 'd', '22 дні'],
89+
[23, 'd', '23 дні'],
90+
[24, 'd', '24 дні'],
91+
92+
// Test all plural forms for months
93+
[1, 'M', 'месяц'],
94+
[2, 'M', '2 месяцы'],
95+
[5, 'M', '5 месяцаў'],
96+
97+
// Test all plural forms for years
98+
[1, 'y', 'год'],
99+
[2, 'y', '2 гады'],
100+
[5, 'y', '5 гадоў'],
101+
[11, 'y', '11 гадоў'],
102+
[21, 'y', '21 год']
83103
]
84104

85105
const locales = ['be']
@@ -100,13 +120,23 @@ it('Belarusian locale relative time in past and future without suffix', () => {
100120
})
101121
})
102122

103-
it('Belarusian locale uses region specific month name', () => {
104-
const locales = [
105-
{ locale: 'be', expectedFormattedDate: 'ср, 19 студзеня 2022 г.' }
123+
it('Belarusian locale formats dates with correct month forms', () => {
124+
const tests = [
125+
// Full month names
126+
{ date: '2022-01-19', format: 'dd, D MMMM YYYY г.', expected: 'ср, 19 студзеня 2022 г.' },
127+
{ date: '2022-01-01', format: 'MMMM', expected: 'студзень' },
128+
129+
// Short month names in format form (with day)
130+
{ date: '2022-01-15', format: 'D MMM', expected: '15 студ' },
131+
{ date: '2022-02-15', format: 'D MMM', expected: '15 лют' },
132+
133+
// Short month names in standalone form
134+
{ date: '2022-01-01', format: 'MMM', expected: 'студ' },
135+
{ date: '2022-02-01', format: 'MMM', expected: 'лют' }
106136
]
107137

108-
locales.forEach((locale) => {
109-
const dayjsWithLocale = dayjs('2022-01-19').locale(locale.locale)
110-
expect(dayjsWithLocale.format('dd, D MMMM YYYY г.')).toEqual(locale.expectedFormattedDate)
138+
tests.forEach(({ date, format, expected }) => {
139+
const dayjsWithLocale = dayjs(date).locale('be')
140+
expect(dayjsWithLocale.format(format)).toEqual(expected)
111141
})
112142
})

0 commit comments

Comments
 (0)