test: add unit-test harness (tsx + node:test) + first suite for utils/common
Addresses the "no automated test suite" gap. Chose Node's built-in test runner via tsx rather than vitest: the project is on Vite 8.0.14, ahead of vitest's supported Vite range, so vitest would fight peer deps. tsx is build-independent. - `npm test` → `node --import tsx --test $(find src -name '*.test.ts')` (works on Node 20 local + 24 CI without relying on --test glob support). - src/app/utils/common.test.ts: 15 tests covering the pure helpers (bytesToSize, time formatters, binarySearch, parseGeoUri, slash trimmers, nameInitials, randomStr, suffixRename, splitWithSpace, promise-settled helpers, etc.) — asserts actual behavior, traced from source. - common.ts: folds import made `import type` (it's types only) so the module is pure and testable without loading folds/CSS. - tsconfig excludes *.test.ts (tsx transpiles tests; eslint isn't type-aware so it still lints them); added an informational CI "Unit tests" step (promote to a hard gate by dropping continue-on-error). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { IconName, IconSrc } from 'folds';
|
||||
import type { IconName, IconSrc } from 'folds';
|
||||
|
||||
export const bytesToSize = (bytes: number): string => {
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
|
||||
|
||||
Reference in New Issue
Block a user