feat(frontend): scaffold i18n init, fr.json (~140 keys), status map, format helpers
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
46
frontend/tests/i18n.test.ts
Normal file
46
frontend/tests/i18n.test.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import i18n from '@/i18n/index';
|
||||
import { engagementStatusLabel, simulationStatusLabel } from '@/i18n/status';
|
||||
import { formatDate, formatDateTime } from '@/lib/format';
|
||||
|
||||
describe('i18n smoke tests', () => {
|
||||
it('resolves common.save to French', () => {
|
||||
expect(i18n.t('common.save')).toBe('Enregistrer');
|
||||
});
|
||||
|
||||
it('missing key returns the key path', () => {
|
||||
expect(i18n.t('this.key.does.not.exist')).toBe('this.key.does.not.exist');
|
||||
});
|
||||
|
||||
it('simulationStatusLabel done → Terminé', () => {
|
||||
expect(simulationStatusLabel('done')).toBe('Terminé');
|
||||
});
|
||||
|
||||
it('engagementStatusLabel active → Actif', () => {
|
||||
expect(engagementStatusLabel('active')).toBe('Actif');
|
||||
});
|
||||
|
||||
it('interpolation inserts the value', () => {
|
||||
expect(i18n.t('engagement.list.deleteConfirm', { name: 'Test' })).toContain('Test');
|
||||
});
|
||||
});
|
||||
|
||||
describe('format helpers', () => {
|
||||
it('formatDate returns — for null', () => {
|
||||
expect(formatDate(null)).toBe('—');
|
||||
});
|
||||
|
||||
it('formatDate returns — for undefined', () => {
|
||||
expect(formatDate(undefined)).toBe('—');
|
||||
});
|
||||
|
||||
it('formatDate formats ISO date in fr-FR', () => {
|
||||
const result = formatDate('2026-06-01');
|
||||
expect(result).toMatch(/\d{2}\/\d{2}\/\d{4}/);
|
||||
});
|
||||
|
||||
it('formatDateTime returns a non-empty string for valid ISO', () => {
|
||||
const result = formatDateTime('2026-06-01T08:00:00');
|
||||
expect(result.length).toBeGreaterThan(0);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user