Commit 6029d83
authored
Add unit tests with vitest (#15)
Vitest as a devDependency. New tests/ directory covers the four
audit-identified pure-function targets:
- duration.test.ts — formatDuration thresholds (ms/s/m/h),
negatives, fractional clamp
- pluralize.test.ts — 1 vs n, custom plurals, negatives
- snapshotParser.test.ts — flat list, no-label rows, escaped-quote
labels, depth from leading whitespace (spaces + tabs), ignored
lines, dedupe, empty input, CRLF
- scriptParser.test.ts — parseScript (blank/comment-only, context
and env directives, action line numbers, comment stripping
outside strings, escaped quotes inside quoted tokens, CRLF) +
interpolate (basic, inside quotes, default fallback, defined
beats default, missing → empty, non-vars untouched) + dequote
(strip + unescape, unquoted passthrough, unbalanced quote)
35 specs total, ~130ms runtime.
To make parseSnapshotRefs importable without VS Code at runtime,
extracted it to src/runners/snapshotParser.ts (no vscode imports).
src/services/snapshotIndex.ts re-exports it for existing callers.
CI runs `npm test` between format:check and compile.
package.json scripts: test (one-shot), test:watch.
.vscodeignore excludes tests, .github, lint/format/test configs
from the published vsix.1 parent 430b997 commit 6029d83
10 files changed
Lines changed: 1641 additions & 98 deletions
File tree
- .github/workflows
- src
- runners
- services
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
4 | 10 | | |
5 | 11 | | |
6 | 12 | | |
| |||
0 commit comments