Road to 10 — Wave 2 · PR-T1

# formatStars unit tests

20 cases · vitest · test debt paydown from #1399

## Function under test

    export const formatStars = (n: number): string =>
      n >= 1000 ? `${(n / 1000).toFixed(n >= 10_000 ? 0 : 1)}k` : `${n}`;

## Coverage

Input | Expected | Note
--- | --- | ---
0 | '0' | small range
1 | '1' | small range
42 | '42' | small range
100 | '100' | small range
999 | '999' | just under "k"
1000 | '1.0k' | enters one-decimal k tier
1500 | '1.5k' | thousands
2400 | '2.4k' | thousands (repo today)
9900 | '9.9k' | near tier boundary
9999 | '10.0k' ⚠ quirk | 9.999 toFixed(1) = "10.0"
10000 | '10k' | enters integer-k tier
10500 | '11k' | half-to-even rounding
12345 | '12k' | ten-thousands
99999 | '100k' | upper edge
100000 | '100k' | hundred-thousands
999000 | '999k' | just under million
1,000,000 | '1000k' ⚠ no-M-tier | revisit at 1M stars
123,456,789 | '123457k' | does not crash on large n
9000 | '9.0k' | tier-boundary test
10000 | '10k' | tier-boundary test

## Why extract?

The function was inline in `docs/site/app/(home)/page.tsx` — untestable without either importing the whole page or duplicating the logic. Moving it to `docs/site/lib/format-stars.ts` gives it a stable import path and makes tests a one-liner.

## Local run

    $ cd docs/site && npm test -- format-stars
     RUN  v4.1.4 /.../docs/site

     Test Files  1 passed (1)
          Tests  20 passed (20)
       Duration  2.05s