test(i18n): cover expanded app locale set
This commit is contained in:
parent
a606f64f03
commit
71e5174082
1 changed files with 8 additions and 10 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { describe, expect, it } from 'vitest';
|
import { describe, expect, it } from 'vitest';
|
||||||
|
|
||||||
|
import { RESOLVED_APP_LOCALES } from '../../../src/features/localization/contracts';
|
||||||
import { validateConfigUpdatePayload } from '../../../src/main/ipc/configValidation';
|
import { validateConfigUpdatePayload } from '../../../src/main/ipc/configValidation';
|
||||||
|
|
||||||
describe('configValidation', () => {
|
describe('configValidation', () => {
|
||||||
|
|
@ -42,16 +43,13 @@ describe('configValidation', () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it.each(['ru', 'zh', 'ja', 'ko', 'es', 'hi', 'pt', 'fr', 'ar', 'bn', 'ur', 'id', 'de'] as const)(
|
it.each(RESOLVED_APP_LOCALES)('accepts supported general.appLocale update %s', (appLocale) => {
|
||||||
'accepts supported general.appLocale update %s',
|
const result = validateConfigUpdatePayload('general', { appLocale });
|
||||||
(appLocale) => {
|
expect(result.valid).toBe(true);
|
||||||
const result = validateConfigUpdatePayload('general', { appLocale });
|
if (result.valid) {
|
||||||
expect(result.valid).toBe(true);
|
expect(result.data).toEqual({ appLocale });
|
||||||
if (result.valid) {
|
|
||||||
expect(result.data).toEqual({ appLocale });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
});
|
||||||
|
|
||||||
it('accepts system general.appLocale updates', () => {
|
it('accepts system general.appLocale updates', () => {
|
||||||
const result = validateConfigUpdatePayload('general', { appLocale: 'system' });
|
const result = validateConfigUpdatePayload('general', { appLocale: 'system' });
|
||||||
|
|
@ -62,7 +60,7 @@ describe('configValidation', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('rejects unsupported general.appLocale updates', () => {
|
it('rejects unsupported general.appLocale updates', () => {
|
||||||
const result = validateConfigUpdatePayload('general', { appLocale: 'uk' });
|
const result = validateConfigUpdatePayload('general', { appLocale: 'xx' });
|
||||||
expect(result.valid).toBe(false);
|
expect(result.valid).toBe(false);
|
||||||
if (!result.valid) {
|
if (!result.valid) {
|
||||||
expect(result.error).toContain('supported app locale');
|
expect(result.error).toContain('supported app locale');
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue