lib/format-date.ts exports a single formatDate(date: Date): string helper that wraps Intl.DateTimeFormat to produce strings like "Jan 15, 2024, 3:45 PM". It currently has no unit test even though sibling utilities like format-duration.ts are well-covered.
- Create
__tests__/lib/format-date.test.ts — copy the structure of __tests__/lib/format-duration.test.ts as a template.
- Import:
import { formatDate } from "@/lib/format-date";
- Add cases for: a fixed UTC date (e.g.
new Date(Date.UTC(2024, 0, 15, 15, 45))), the start of a month, midnight, single-digit day, and end of year. Assert against the exact expected string.
- Run
bun run test:run and confirm all cases pass.
Out of scope: changing format-date.ts itself, or adding locale handling. Just lock in current behavior.
lib/format-date.tsexports a singleformatDate(date: Date): stringhelper that wrapsIntl.DateTimeFormatto produce strings like"Jan 15, 2024, 3:45 PM". It currently has no unit test even though sibling utilities likeformat-duration.tsare well-covered.__tests__/lib/format-date.test.ts— copy the structure of__tests__/lib/format-duration.test.tsas a template.import { formatDate } from "@/lib/format-date";new Date(Date.UTC(2024, 0, 15, 15, 45))), the start of a month, midnight, single-digit day, and end of year. Assert against the exact expected string.bun run test:runand confirm all cases pass.Out of scope: changing
format-date.tsitself, or adding locale handling. Just lock in current behavior.