47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
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);
|
|
});
|
|
});
|