16import {
messages } from
'../modules/messageReference';
18suite(
'MessageReference Hardening', () => {
19 const locales = Object.keys(
messages).sort();
20 const expectedLocales = [
'cs',
'de',
'en',
'es',
'fr',
'hu',
'it',
'ja',
'ko',
'pl',
'pt-br',
'ru',
'tr',
'zh-cn',
'zh-tw'].sort();
21 const enKeys = Object.keys(
messages.en).sort();
23 test(
'should expose exactly 15 locales', () => {
24 assert.deepStrictEqual(locales, expectedLocales, `Locales mismatch: got ${locales.join(
',')}`);
27 test(
'en should have at least 140 keys (currently 148)', () => {
29 assert.ok(enKeys.length >= 140, `en has ${enKeys.length} keys, expected >=140`);
30 assert.ok(enKeys.length < 300, `en has ${enKeys.length} keys, suspicious growth`);
33 test(
'every locale should have exactly the same keys as en', () => {
34 for (
const locale of locales) {
35 const keys = Object.keys(
messages[locale]).sort();
36 const missing = enKeys.filter(k => !keys.includes(k));
37 const extra = keys.filter(k => !enKeys.includes(k));
38 assert.strictEqual(missing.length, 0, `Locale ${locale} missing keys: ${missing.join(
', ')}`);
39 assert.strictEqual(extra.length, 0, `Locale ${locale} has extra keys: ${extra.join(
', ')}`);
43 test(
'every message value should be a function returning string', () => {
44 for (
const locale of locales) {
45 for (
const key of enKeys) {
46 const fn = (
messages[locale] as any)[key];
47 assert.strictEqual(typeof fn,
'function', `${locale}.${key} should be
function`);
51 result = fn(
'a',
'b',
'c', 123);
56 assert.strictEqual(typeof result,
'string', `${locale}.${key}() should
return string`);
57 assert.ok(result.length >= 0, `${locale}.${key}() should not be empty check`);
62 test(
'new 1.0.21/1.0.22 keys should exist in every locale', () => {
63 const newKeys = [
'headerLogoReference',
'headerLogoReferenceNotFound',
'headerLogoReferenceNotFoundGUI',
'headerLogoVersionDisabled'];
64 for (
const k of newKeys) {
66 for (
const locale of locales) {
export const export const string[]
import *as assert from assert
export const messages
Complete message dictionary for all supported languages with type-safe function interfaces @export Ex...