Files
weirsoe-party-protocol/frontend/tests/lobby-loader.parity.test.ts
DEV-bot f87e0b60cf
All checks were successful
CI / test-and-quality (push) Successful in 3m13s
CI / test-and-quality (pull_request) Successful in 2m55s
test(i18n): normalize underscore locale tags in shared frontend loader (#257)
2026-03-02 03:02:04 +00:00

39 lines
1.3 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import {
collectLocaleParityIssues,
LOBBY_I18N_CATALOG,
normalizeLocale,
SUPPORTED_LOCALES,
translateCatalogPath,
} from '../shared/i18n/lobby-loader';
describe('shared lobby i18n loader parity', () => {
it('keeps da/en translation parity in shared keyspace', () => {
const issues = collectLocaleParityIssues(LOBBY_I18N_CATALOG, SUPPORTED_LOCALES);
expect(issues).toEqual([]);
});
it('normalizes browser-style locale tags to supported keyspace locales', () => {
expect(normalizeLocale('da-DK')).toBe('da');
expect(normalizeLocale('da_DK')).toBe('da');
expect(normalizeLocale('en-US')).toBe('en');
expect(normalizeLocale('en_US')).toBe('en');
expect(normalizeLocale('fr-FR')).toBe('en');
});
it('resolves shared frontend ui keys with fallback-safe behavior', () => {
expect(
translateCatalogPath(LOBBY_I18N_CATALOG.frontend.ui as Record<string, unknown>, 'host.start_round', 'da-DK'),
).toBe('Start runde');
expect(
translateCatalogPath(LOBBY_I18N_CATALOG.frontend.ui as Record<string, unknown>, 'app.language_label', 'en-US'),
).toBe('Language');
expect(
translateCatalogPath(LOBBY_I18N_CATALOG.frontend.ui as Record<string, unknown>, 'host.non_existing_key', 'da'),
).toBe('host.non_existing_key');
});
});