Skip to content

Add Vitest test suite with 96 tests - #5

Merged
tylergraydev merged 7 commits into
mainfrom
feature/add-vitest-tests
Dec 17, 2025
Merged

Add Vitest test suite with 96 tests#5
tylergraydev merged 7 commits into
mainfrom
feature/add-vitest-tests

Conversation

@tylergraydev

@tylergraydev tylergraydev commented Dec 17, 2025

Copy link
Copy Markdown
Owner

Summary

Adds comprehensive test suite using Vitest with 155 tests across 10 test files.

Test Coverage

Module Tests Coverage
config/loader 7 Config loading, merging, fallbacks
themes 37 Theme retrieval, color validation
segments/block 8 Block segment, time calculations
segments/weekly 10 Weekly segment, week progress
utils/oauth 10 API responses, caching
utils/claude-hook 21 Model name formatting
utils/environment 20 Git branch, directory detection
utils/terminal 13 Terminal width, ANSI handling
utils/logger 8 Debug/error logging
renderer 21 Segment rendering, ordering

Coverage Summary

Module Before After
Segments 0% 85%
Utils 20% 43%
Themes 100% 100%
Config 100% 100%
Overall 45% 70%

New Scripts

npm test           # Run tests once
npm run test:watch # Watch mode
npm run test:coverage # Coverage report

Test Results

 Test Files  10 passed (10)
      Tests  155 passed (155)
   Duration  721ms

Test plan

  • All 155 tests pass
  • Typecheck passes
  • Config loading tested
  • All 6 themes validated
  • Block and weekly segments tested
  • OAuth API response parsing tested
  • Git functions tested
  • Terminal utilities tested

🤖 Generated with Claude Code

Tyler Gray and others added 7 commits December 17, 2025 14:21
- Configure Vitest for ESM TypeScript
- Add tests for config loader (7 tests)
- Add tests for themes module (37 tests)
- Add tests for claude-hook utilities (21 tests)
- Add tests for environment utilities (10 tests)
- Add tests for renderer (21 tests)

Test coverage includes:
- Config file loading and merging
- Theme retrieval and structure validation
- Model name formatting
- Segment rendering and ordering
- Trend arrows and compact mode
- Warning/critical color states

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Use correct interface properties (resetAt, isRealtime) instead of
non-existent ones (currentUsage, limit).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Document Vitest setup, test commands, and test structure.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
New test files:
- src/segments/block.test.ts (8 tests)
- src/segments/weekly.test.ts (10 tests)
- src/utils/oauth.test.ts (10 tests)
- src/utils/terminal.test.ts (13 tests)
- src/utils/logger.test.ts (8 tests)

Updated tests:
- src/utils/environment.test.ts (+10 tests for git functions)

Coverage improvements:
- Segments: 0% → 85%
- Utils: 20% → 43%
- Overall: 45% → 69%

Total: 155 tests passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Update test count from 96 to 155
- Add all 10 test files to the table
- Document segments and utils tests

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Tests must pass for CI to succeed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Use forward slashes instead of backslashes since path.basename
on Linux doesn't recognize backslash as a path separator.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@tylergraydev
tylergraydev merged commit 9618314 into main Dec 17, 2025
3 checks passed
@tylergraydev
tylergraydev deleted the feature/add-vitest-tests branch December 17, 2025 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant