Files
faunosteo/apps/app/tests/unit/lib.dates.test.ts
T
bchanot 8673475293 chore(workspace): move the app to apps/app under a pnpm workspace (step 2)
144 files moved with git mv (pure renames). Root package.json delegates
dev/typecheck/test:run/lint/build to the packages; Node 24 LTS and
pnpm 10.13.1 pinned (.nvmrc, .node-version, engines, packageManager,
root devDependency, engine-strict). Dockerfile builds @faunosteo/app on
node:24-alpine and copies apps/app/dist; nginx and runtime config
unchanged. CI workflow for Gitea Actions. packages/ reserved (README only).
Docs synced: WORKSPACE.md, CLAUDE.md, README, DEPLOY, CHANGELOG, plan.
271/271 tests, typecheck, lint, build green from the root.
2026-10-08 21:51:13 +02:00

41 lines
1.1 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { formatDate, todayIso, nowIso } from '@/lib/dates'
describe('formatDate fr', () => {
it('formats "2026-05-18" as "18 mai 2026"', () => {
expect(formatDate('2026-05-18', 'fr')).toBe('18 mai 2026')
})
it('drops leading zero on the day', () => {
expect(formatDate('2026-01-03', 'fr')).toBe('3 janvier 2026')
})
})
describe('formatDate en', () => {
it('formats "2026-05-18" as "May 18, 2026"', () => {
expect(formatDate('2026-05-18', 'en')).toBe('May 18, 2026')
})
it('drops leading zero on the day', () => {
expect(formatDate('2026-01-03', 'en')).toBe('January 3, 2026')
})
})
describe('formatDate edge', () => {
it('throws on invalid ISO input', () => {
expect(() => formatDate('not-a-date', 'fr')).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}/)
})
})