feat: add i18n dictionaries and service data
Locale-aware EN/FR string dictionaries and the two-service data model (CVE Watch with per-locale URLs, Convert with a single URL).
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { en } from '../src/i18n/en';
|
||||
import { fr } from '../src/i18n/fr';
|
||||
import { getDictionary } from '../src/i18n';
|
||||
import { otherLocale, swapLocalePath, locales } from '../src/i18n/locale';
|
||||
import { services, resolveServiceUrl } from '../src/i18n/services';
|
||||
|
||||
describe('i18n dictionaries', () => {
|
||||
it('exposes both locales', () => {
|
||||
expect(locales).toEqual(['en', 'fr']);
|
||||
});
|
||||
|
||||
it('fr and en dictionaries have the same keys', () => {
|
||||
expect(Object.keys(fr)).toEqual(Object.keys(en));
|
||||
expect(Object.keys(fr.hero)).toEqual(Object.keys(en.hero));
|
||||
expect(Object.keys(fr.theme)).toEqual(Object.keys(en.theme));
|
||||
});
|
||||
|
||||
it('getDictionary resolves the right dictionary', () => {
|
||||
expect(getDictionary('en')).toBe(en);
|
||||
expect(getDictionary('fr')).toBe(fr);
|
||||
});
|
||||
|
||||
it('otherLocale flips locale', () => {
|
||||
expect(otherLocale('en')).toBe('fr');
|
||||
expect(otherLocale('fr')).toBe('en');
|
||||
});
|
||||
|
||||
it('swapLocalePath swaps the locale segment', () => {
|
||||
expect(swapLocalePath('/en/', 'en', 'fr')).toBe('/fr/');
|
||||
});
|
||||
});
|
||||
|
||||
describe('services data', () => {
|
||||
it('resolves a locale-specific url', () => {
|
||||
const cve = services.find((s) => s.id === 'cve')!;
|
||||
expect(resolveServiceUrl(cve, 'en')).toBe('https://cve-en.ombrora.com');
|
||||
expect(resolveServiceUrl(cve, 'fr')).toBe('https://cve-fr.ombrora.com');
|
||||
});
|
||||
|
||||
it('resolves a single-url service the same for both locales', () => {
|
||||
const convert = services.find((s) => s.id === 'convert')!;
|
||||
expect(resolveServiceUrl(convert, 'en')).toBe('https://convert.ombrora.com');
|
||||
expect(resolveServiceUrl(convert, 'fr')).toBe('https://convert.ombrora.com');
|
||||
});
|
||||
|
||||
it('has exactly two services: cve and convert', () => {
|
||||
expect(services.map((s) => s.id).sort()).toEqual(['convert', 'cve']);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user