From ae0185cab0d9efaf13197157d331283b8636347a Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Thu, 30 Mar 2023 13:59:02 +0800 Subject: [PATCH] refactor: fix test --- packages/core/src/__mocks__/custom-phrase.ts | 4 ++-- packages/core/src/libraries/phrase.test.ts | 4 ++-- .../routes/well-known.phrases.content-language.test.ts | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/core/src/__mocks__/custom-phrase.ts b/packages/core/src/__mocks__/custom-phrase.ts index 792f05e2b..042812d9b 100644 --- a/packages/core/src/__mocks__/custom-phrase.ts +++ b/packages/core/src/__mocks__/custom-phrase.ts @@ -6,7 +6,7 @@ import { mockId } from '#src/test-utils/nanoid.js'; export const enTag = 'en'; export const trTrTag = 'tr-TR'; export const zhCnTag = 'zh-CN'; -export const zhHkTag = 'zh-HK'; +export const mockTag = 'fo-BA'; export const mockEnCustomPhrase = { tenantId: 'fake_tenant', @@ -66,7 +66,7 @@ export const mockZhCnCustomPhrase = { export const mockZhHkCustomPhrase = { tenantId: 'fake_tenant', id: mockId, - languageTag: zhHkTag, + languageTag: mockTag, translation: { input: { email: '郵箱 1', diff --git a/packages/core/src/libraries/phrase.test.ts b/packages/core/src/libraries/phrase.test.ts index 38671a5ad..0478e17f0 100644 --- a/packages/core/src/libraries/phrase.test.ts +++ b/packages/core/src/libraries/phrase.test.ts @@ -9,7 +9,7 @@ import { mockZhHkCustomPhrase, trTrTag, zhCnTag, - zhHkTag, + mockTag, } from '#src/__mocks__/custom-phrase.js'; import { wellKnownCache } from '#src/caches/well-known.js'; import RequestError from '#src/errors/RequestError/index.js'; @@ -19,7 +19,7 @@ const { jest } = import.meta; const englishBuiltInPhrase = resource[enTag]; -const customOnlyLanguage = zhHkTag; +const customOnlyLanguage = mockTag; const customOnlyCustomPhrase = mockZhHkCustomPhrase; const customizedLanguage = zhCnTag; diff --git a/packages/core/src/routes/well-known.phrases.content-language.test.ts b/packages/core/src/routes/well-known.phrases.content-language.test.ts index a681d79d2..33236ea36 100644 --- a/packages/core/src/routes/well-known.phrases.content-language.test.ts +++ b/packages/core/src/routes/well-known.phrases.content-language.test.ts @@ -2,7 +2,7 @@ import en from '@logto/phrases-ui/lib/locales/en/index.js'; import type { SignInExperience } from '@logto/schemas'; import { pickDefault } from '@logto/shared/esm'; -import { trTrTag, zhCnTag, zhHkTag } from '#src/__mocks__/custom-phrase.js'; +import { trTrTag, zhCnTag, mockTag } from '#src/__mocks__/custom-phrase.js'; import { mockSignInExperience } from '#src/__mocks__/index.js'; import { wellKnownCache } from '#src/caches/well-known.js'; import { MockTenant } from '#src/test-utils/tenant.js'; @@ -58,7 +58,7 @@ describe('when auto-detect is not enabled', () => { }); const response = await phraseRequest .get('/.well-known/phrases') - .set('Accept-Language', `${zhCnTag},${zhHkTag}`); + .set('Accept-Language', `${zhCnTag},${mockTag}`); expect(response.headers['content-language']).toEqual('en'); }); @@ -81,7 +81,7 @@ describe('when auto-detect is not enabled', () => { it('when there are detected languages', async () => { const response = await phraseRequest .get('/.well-known/phrases') - .set('Accept-Language', `${zhCnTag},${zhHkTag}`); + .set('Accept-Language', `${zhCnTag},${mockTag}`); expect(response.headers['content-language']).toEqual(fallbackLanguage); }); }); @@ -135,7 +135,7 @@ describe('when auto-detect is enabled', () => { const firstSupportedLanguage = zhCnTag; const response = await phraseRequest .get('/.well-known/phrases') - .set('Accept-Language', `${unsupportedLanguageX},${firstSupportedLanguage},${zhHkTag}`); + .set('Accept-Language', `${unsupportedLanguageX},${firstSupportedLanguage},${mockTag}`); expect(response.headers['content-language']).toEqual(firstSupportedLanguage); }); });