From 33c531e60c2079c573038e9e153159ae28cdec73 Mon Sep 17 00:00:00 2001 From: Johnson Mao Date: Thu, 26 Oct 2023 21:40:37 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20fix=20i18n=20test=20failures?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Link/link.test.tsx | 4 ++-- src/hooks/__tests__/useI18n.test.ts | 6 +++--- src/utils/__tests__/getLocale.test.ts | 10 +++++----- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/Link/link.test.tsx b/src/components/Link/link.test.tsx index 9696d375..adbf1a48 100644 --- a/src/components/Link/link.test.tsx +++ b/src/components/Link/link.test.tsx @@ -33,8 +33,8 @@ describe('Link component', () => { it.each([ ['/internal', '/internal'], ['/en/internal', '/en/internal'], - ['/zh-TW/internal', '/zh-TW/internal'], - ['/fr-CH/internal', '/internal'], + ['/zh/internal', '/zh/internal'], + ['/fr/internal', '/internal'], ])( 'should render correct link element with pathname %s', (pathname, expected) => { diff --git a/src/hooks/__tests__/useI18n.test.ts b/src/hooks/__tests__/useI18n.test.ts index 6bb43170..c4da28a5 100644 --- a/src/hooks/__tests__/useI18n.test.ts +++ b/src/hooks/__tests__/useI18n.test.ts @@ -13,10 +13,10 @@ describe('useI18n hook', () => { }); it.each([ - ['/test/path', 'zh-TW'], + ['/test/path', 'zh'], ['/en/test/path', 'en'], - ['/zh-TW/test/path', 'zh-TW'], - ['/fr-CH/test/path', 'zh-TW'], + ['/zh/test/path', 'zh'], + ['/fr/test/path', 'zh'], ])( 'should return the correct language code and dictionary', (pathname, expected) => { diff --git a/src/utils/__tests__/getLocale.test.ts b/src/utils/__tests__/getLocale.test.ts index ddfcda35..5539d41c 100644 --- a/src/utils/__tests__/getLocale.test.ts +++ b/src/utils/__tests__/getLocale.test.ts @@ -8,9 +8,9 @@ describe('get locale function', () => { }); it.each([ - ['zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7', 'zh-TW'], + ['zh-TW,zh;q=0.9,en-US;q=0.8,en;q=0.7', 'zh'], ['en-US,en;q=0.9,zh-TW;q=0.8,ja;q=0.7', 'en'], - ['fr-CH,fr;q=0.9,de-CH;q=0.8,de;q=0.7', 'zh-TW'], + ['fr-CH,fr;q=0.9,de-CH;q=0.8,de;q=0.7', 'zh'], ])( 'should extract the preferred language code from the Accept-Language header', (acceptLanguage, expected) => { @@ -19,10 +19,10 @@ describe('get locale function', () => { ); it.each([ - ['/test/path', 'zh-TW'], + ['/test/path', 'zh'], ['/en/test/path', 'en'], - ['/zh-TW/test/path', 'zh-TW'], - ['/fr-CH/test/path', 'zh-TW'], + ['/zh/test/path', 'zh'], + ['/fr/test/path', 'zh'], ])( 'should extract the language code from the path string', (pathname, expected) => {