feat(lib): implement formatDateFr (fr-FR locale)
This commit is contained in:
1 parent
ff3989c41f
commit
8b9eb61a69
2 files changed
+40
-2
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { formatDateFr, todayIso, nowIso } from '@/lib/dates'
|
||||
|
||||
describe('formatDateFr', () => {
|
||||
it('formats an ISO date as "18 mai 2026"', () => {
|
||||
expect(formatDateFr('2026-05-18')).toBe('18 mai 2026')
|
||||
})
|
||||
|
||||
it('formats a leading-zero day correctly', () => {
|
||||
expect(formatDateFr('2026-01-03')).toBe('3 janvier 2026')
|
||||
})
|
||||
|
||||
it('throws on invalid input', () => {
|
||||
expect(() => formatDateFr('not-a-date')).toThrow()
|
||||
})
|
||||
})
|
||||
|
||||
describe('todayIso', () => {
|
||||
it('returns YYYY-MM-DD', () => {
|
||||
expect(todayIso()).toMatch(/^\d{4}-\d{2}-\d{2}$/)
|
||||
})
|
||||
})
|
||||
|
||||
describe('nowIso', () => {
|
||||
it('returns a full ISO instant', () => {
|
||||
expect(nowIso()).toMatch(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/)
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user