X
Utilities Test Coverage
Utility tests live in apps/dashboard/__tests__/utils and protect the core
formatting, parsing, and validation helpers that many product areas depend on.
Because these functions back invoices, reporting, onboarding, and more, the
suite focuses on correctness across locales, edge cases, and unexpected input.
Suites
date-utils.test.ts: targetsdateToUnixSecondsfrom@/lib/date-utils. The cases span multiple human-readable formats (DD MMM YYYY,MMM DD YYYY), locale-aware month parsing, whitespace handling, and fallbacks toDate.parsefor ISO-style strings.formatting-utils.test.ts: exercisesformatNumberToCurrency,getCurrencySymbol, andformatLargeNumber. The coverage includes currency symbol mapping, locale separators, decimal precision, compact notation (Mil/Bil), and cents-to-unit conversions for integer values between 1 000 and 99 999.unix-conversion.test.ts: validatesunixToLocalDateandunixToLocalTimefrom@/lib/utils, ensuring timestamps convert to human-friendly date and 24-hour time strings while gracefully handling negative, zero, and distant future values.validation-utils.test.ts: stressesvalidateEmailwith real-world, malformed, and edge-case addresses to guarantee we reject invalid contact info before it reaches Supabase.
Running the suite
Run everything:
pnpm vitest run apps/dashboard/__tests__/utils
```typescript
Iterate on a single helper (for example, email validation):
```bash
pnpm vitest run apps/dashboard/__tests__/utils/validation-utils.test.ts
```typescript
### Test data & patterns
- Tests rely solely on deterministic inputs—no network or time mocks are
required. Add new edge cases by expanding the inline arrays inside each file.
- Locale-sensitive expectations use `toContain` instead of hard-coded strings
when separators differ per environment. Follow that pattern when asserting
formatted currency.
- Keep new helpers colocated; if a utility exports multiple functions, prefer a
dedicated `describe` block for each to mirror the existing layout.