Initial commit

This commit is contained in:
pigui
2026-08-30 21:11:59 +02:00
commit 3f930bb46a
168 changed files with 35708 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import { describe, expect, it } from 'vitest';
import { DEFAULT_LOCALE, localeFromUrl, resolveLocale } from './api';
describe('resolveLocale', () => {
it('accepts the locales the API declares', () => {
expect(resolveLocale('ca')).toBe('ca');
expect(resolveLocale('en')).toBe('en');
});
it('falls back to the application default for anything else', () => {
expect(resolveLocale('fr')).toBe(DEFAULT_LOCALE);
expect(resolveLocale(undefined)).toBe(DEFAULT_LOCALE);
expect(resolveLocale(42)).toBe(DEFAULT_LOCALE);
});
});
describe('localeFromUrl', () => {
it('reads ?lang from a path-only URL', () => {
expect(localeFromUrl('/api/_analog/pages/-home-?lang=ca')).toBe('ca');
});
it('ignores an unsupported language rather than passing it on', () => {
expect(localeFromUrl('/?lang=de')).toBe(DEFAULT_LOCALE);
});
it('survives a missing URL', () => {
expect(localeFromUrl(undefined)).toBe(DEFAULT_LOCALE);
});
});