diff options
Diffstat (limited to 'web_src/js/utils.test.js')
-rw-r--r-- | web_src/js/utils.test.js | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/web_src/js/utils.test.js b/web_src/js/utils.test.js index 7bf5bb7eb6..0567a5c64a 100644 --- a/web_src/js/utils.test.js +++ b/web_src/js/utils.test.js @@ -1,7 +1,7 @@ import {expect, test} from 'vitest'; import { basename, extname, isObject, uniq, stripTags, joinPaths, parseIssueHref, - prettyNumber, parseUrl, + prettyNumber, parseUrl, translateMonth, translateDay } from './utils.js'; test('basename', () => { @@ -109,3 +109,25 @@ test('parseUrl', () => { expect(parseUrl('https://localhost/path?search').search).toEqual('?search'); expect(parseUrl('https://localhost/path?search#hash').hash).toEqual('#hash'); }); + +test('translateMonth', () => { + const originalLang = document.documentElement.lang; + document.documentElement.lang = 'en-US'; + expect(translateMonth(0)).toEqual('Jan'); + expect(translateMonth(4)).toEqual('May'); + document.documentElement.lang = 'es-ES'; + expect(translateMonth(5)).toEqual('jun'); + expect(translateMonth(6)).toEqual('jul'); + document.documentElement.lang = originalLang; +}); + +test('translateDay', () => { + const originalLang = document.documentElement.lang; + document.documentElement.lang = 'fr-FR'; + expect(translateDay(1)).toEqual('lun.'); + expect(translateDay(5)).toEqual('ven.'); + document.documentElement.lang = 'pl-PL'; + expect(translateDay(1)).toEqual('pon.'); + expect(translateDay(5)).toEqual('pt.'); + document.documentElement.lang = originalLang; +}); |