test: increase coverage for token-usage.ts (55%→95%) and vscode-sessions.ts (45%→92%) - #172
Open
kannupriyakalra wants to merge 1 commit into
Open
test: increase coverage for token-usage.ts (55%→95%) and vscode-sessions.ts (45%→92%)#172kannupriyakalra wants to merge 1 commit into
kannupriyakalra wants to merge 1 commit into
Conversation
token-usage.ts: 55% → 95% statements
- Adds tests for parseClaudeCodeJsonl (0% → fully covered): sidechain skip,
synthetic model skip, missing usage, zero-total skip, malformed JSON lines,
multi-line files
- Adds tests for getTokenUsage source filtering (copilot-cli / claude-code / all)
using temp-dir fixtures + vi.mock("os")
- Adds weekly/monthly bucket and per-model breakdown tests to aggregate suite
vscode-sessions.ts: 45% → 92% statements
- New vscode-sessions-api.test.ts tests the public API (listVSCodeSessions,
getVSCodeSession, isVSCodeSession, getVSCodeAnalytics) with a configurable
better-sqlite3 mock and temp-dir session JSON fixtures
- Key fix: Vitest 4 requires regular functions (not arrow functions) in
mockImplementation when the mock is called with `new`
Closes #170
Closes #171
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
token-usage.ts: 55% → 95% statementsvscode-sessions.ts: 45% → 92% statementsWhat was added
token-usage.test.tsparseClaudeCodeJsonl: sidechain skip,<synthetic>model skip, missing usage, zero-total skip, malformed JSON, multi-line filesgetTokenUsagesource filtering tests (copilot-cli/claude-code/all) using temp-dir fixtures +vi.mock("os")aggregatevscode-sessions-api.test.ts(new file)listVSCodeSessions,getVSCodeSession,isVSCodeSession,getVSCodeAnalyticsagainst real temp-dir session JSON filesbetter-sqlite3mock viamockDatabase()helperfunctionexpressions (not arrow functions) inmockImplementationwhen the mock is called withnew— arrow functions throw "is not a constructor"Test plan
npm test— all 147 tests passnpx vitest run --coverage— confirm token-usage.ts ≥ 95%, vscode-sessions.ts ≥ 90%Closes #170
Closes #171
🤖 Generated with Claude Code