Add Bun tests for resolveConfig and loadConfigFile

Two new test files exercise the layered config resolver and the JSON
config-file loader:

  src/config.test.ts        25 cases:
    - resolveConfig precedence (CLI > file > default) per field
    - seconds-to-ms conversion at the resolver boundary
    - verbose precedence across all four cells
    - defaultConfigPath: XDG honored, HOME fallback, empty-as-unset,
      throws CliError when both are missing

  src/configFile.test.ts    11 cases:
    - valid file -> overrides, with undefined for unspecified keys
    - missing explicit path throws
    - malformed JSON / non-object root throws with file path
    - unknown key / wrong type / non-positive number all throw with
      the offending key named
    - default path missing -> null (silent default)

Runs via 'bun test' (or 'bun run test', now wired in package.json).
All 25 tests pass on the current codebase.
This commit is contained in:
2026-06-17 16:34:27 -05:00
parent 5af253283e
commit 1a857de5ed
3 changed files with 245 additions and 1 deletions
+2 -1
View File
@@ -11,7 +11,8 @@
"bun": ">=1.0.0"
},
"scripts": {
"start": "bun run src/move.ts"
"start": "bun run src/move.ts",
"test": "bun test"
},
"dependencies": {
"@nut-tree-fork/nut-js": "^4.2.2"