import { languageLinks, parseLocalePath } from './i18n' describe('parseLocalePath (MITHOME-115)', () => { it.each([ ['/hu/rolunk', { locale: 'hu', slug: 'rolunk' }], ['/en', { locale: 'en', slug: undefined }], ['/en/services/', { locale: 'en', slug: 'services' }], ['/', { locale: 'hu' }], ['/admin', { locale: 'hu' }], ])('should parse %s', (path, expected) => { expect(parseLocalePath(path)).toEqual(expected) }) }) describe('languageLinks (MITHOME-115)', () => { it('should keep the current page with its translated slug', () => { expect(languageLinks('/hu/szolgaltatasok')).toEqual([ { locale: 'hu', href: '/hu/szolgaltatasok', isActive: true }, { locale: 'en', href: '/en/services', isActive: false }, ]) expect(languageLinks('/en/privacy-policy').map((l) => l.href)).toEqual(['/hu/adatvedelem', '/en/privacy-policy']) // MITHOME-130 expect(languageLinks('/hu/tarhely-csomagok').map((l) => l.href)).toEqual(['/hu/tarhely-csomagok', '/en/hosting-plans']) }) it('should link the home pages from a home page', () => { expect(languageLinks('/en').map((l) => [l.href, l.isActive])).toEqual([ ['/hu', false], ['/en', true], ]) }) it('should fall back to the other language home for an unknown page', () => { expect(languageLinks('/hu/nincs-ilyen').map((l) => l.href)).toEqual(['/hu', '/en']) }) })