mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
refactor: fix test
This commit is contained in:
parent
5c50957a95
commit
ae0185cab0
3 changed files with 8 additions and 8 deletions
|
@ -6,7 +6,7 @@ import { mockId } from '#src/test-utils/nanoid.js';
|
||||||
export const enTag = 'en';
|
export const enTag = 'en';
|
||||||
export const trTrTag = 'tr-TR';
|
export const trTrTag = 'tr-TR';
|
||||||
export const zhCnTag = 'zh-CN';
|
export const zhCnTag = 'zh-CN';
|
||||||
export const zhHkTag = 'zh-HK';
|
export const mockTag = 'fo-BA';
|
||||||
|
|
||||||
export const mockEnCustomPhrase = {
|
export const mockEnCustomPhrase = {
|
||||||
tenantId: 'fake_tenant',
|
tenantId: 'fake_tenant',
|
||||||
|
@ -66,7 +66,7 @@ export const mockZhCnCustomPhrase = {
|
||||||
export const mockZhHkCustomPhrase = {
|
export const mockZhHkCustomPhrase = {
|
||||||
tenantId: 'fake_tenant',
|
tenantId: 'fake_tenant',
|
||||||
id: mockId,
|
id: mockId,
|
||||||
languageTag: zhHkTag,
|
languageTag: mockTag,
|
||||||
translation: {
|
translation: {
|
||||||
input: {
|
input: {
|
||||||
email: '郵箱 1',
|
email: '郵箱 1',
|
||||||
|
|
|
@ -9,7 +9,7 @@ import {
|
||||||
mockZhHkCustomPhrase,
|
mockZhHkCustomPhrase,
|
||||||
trTrTag,
|
trTrTag,
|
||||||
zhCnTag,
|
zhCnTag,
|
||||||
zhHkTag,
|
mockTag,
|
||||||
} from '#src/__mocks__/custom-phrase.js';
|
} from '#src/__mocks__/custom-phrase.js';
|
||||||
import { wellKnownCache } from '#src/caches/well-known.js';
|
import { wellKnownCache } from '#src/caches/well-known.js';
|
||||||
import RequestError from '#src/errors/RequestError/index.js';
|
import RequestError from '#src/errors/RequestError/index.js';
|
||||||
|
@ -19,7 +19,7 @@ const { jest } = import.meta;
|
||||||
|
|
||||||
const englishBuiltInPhrase = resource[enTag];
|
const englishBuiltInPhrase = resource[enTag];
|
||||||
|
|
||||||
const customOnlyLanguage = zhHkTag;
|
const customOnlyLanguage = mockTag;
|
||||||
const customOnlyCustomPhrase = mockZhHkCustomPhrase;
|
const customOnlyCustomPhrase = mockZhHkCustomPhrase;
|
||||||
|
|
||||||
const customizedLanguage = zhCnTag;
|
const customizedLanguage = zhCnTag;
|
||||||
|
|
|
@ -2,7 +2,7 @@ import en from '@logto/phrases-ui/lib/locales/en/index.js';
|
||||||
import type { SignInExperience } from '@logto/schemas';
|
import type { SignInExperience } from '@logto/schemas';
|
||||||
import { pickDefault } from '@logto/shared/esm';
|
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 { mockSignInExperience } from '#src/__mocks__/index.js';
|
||||||
import { wellKnownCache } from '#src/caches/well-known.js';
|
import { wellKnownCache } from '#src/caches/well-known.js';
|
||||||
import { MockTenant } from '#src/test-utils/tenant.js';
|
import { MockTenant } from '#src/test-utils/tenant.js';
|
||||||
|
@ -58,7 +58,7 @@ describe('when auto-detect is not enabled', () => {
|
||||||
});
|
});
|
||||||
const response = await phraseRequest
|
const response = await phraseRequest
|
||||||
.get('/.well-known/phrases')
|
.get('/.well-known/phrases')
|
||||||
.set('Accept-Language', `${zhCnTag},${zhHkTag}`);
|
.set('Accept-Language', `${zhCnTag},${mockTag}`);
|
||||||
expect(response.headers['content-language']).toEqual('en');
|
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 () => {
|
it('when there are detected languages', async () => {
|
||||||
const response = await phraseRequest
|
const response = await phraseRequest
|
||||||
.get('/.well-known/phrases')
|
.get('/.well-known/phrases')
|
||||||
.set('Accept-Language', `${zhCnTag},${zhHkTag}`);
|
.set('Accept-Language', `${zhCnTag},${mockTag}`);
|
||||||
expect(response.headers['content-language']).toEqual(fallbackLanguage);
|
expect(response.headers['content-language']).toEqual(fallbackLanguage);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -135,7 +135,7 @@ describe('when auto-detect is enabled', () => {
|
||||||
const firstSupportedLanguage = zhCnTag;
|
const firstSupportedLanguage = zhCnTag;
|
||||||
const response = await phraseRequest
|
const response = await phraseRequest
|
||||||
.get('/.well-known/phrases')
|
.get('/.well-known/phrases')
|
||||||
.set('Accept-Language', `${unsupportedLanguageX},${firstSupportedLanguage},${zhHkTag}`);
|
.set('Accept-Language', `${unsupportedLanguageX},${firstSupportedLanguage},${mockTag}`);
|
||||||
expect(response.headers['content-language']).toEqual(firstSupportedLanguage);
|
expect(response.headers['content-language']).toEqual(firstSupportedLanguage);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue