Closed
Description
I have an error with this fix because my timezone isn't the expected one:
FAIL web_src/js/utils.test.js > translateDay
AssertionError: expected 'dim.' to deeply equal 'lun.'
❯ web_src/js/utils.test.js:127:27
125| const originalLang = document.documentElement.lang;
126| document.documentElement.lang = 'fr-FR';
127| expect(translateDay(1)).toEqual('lun.');
| ^
128| expect(translateDay(5)).toEqual('ven.');
129| document.documentElement.lang = 'pl-PL';
- Expected "lun."
+ Received "dim."
I suggest the fix must considered the same timezone (UTC) for the localised test:
// given a month (0-11), returns it in the documents language
export function translateMonth(month) {
- return new Date(Date.UTC(2022, month, 12)).toLocaleString(getCurrentLocale(), {month: 'short'});
+ return new Date(Date.UTC(2022, month, 12)).toLocaleString(getCurrentLocale(), {month: 'short', timeZone: 'UTC'});
}
// given a weekday (0-6, Sunday to Saturday), returns it in the documents language
export function translateDay(day) {
- return new Date(Date.UTC(2022, 7, day)).toLocaleString(getCurrentLocale(), {weekday: 'short'});
+ return new Date(Date.UTC(2022, 7, day)).toLocaleString(getCurrentLocale(), {weekday: 'short', timeZone: 'UTC'});
}
ping @yardenshoham
Originally posted by @fsologureng in #15541 (comment)