Skip to content

test: add comprehensive unit tests for src/utils/index.ts - #31

Merged
GoBeromsu merged 1 commit into
masterfrom
test/utils-index-unit-tests
Dec 28, 2025
Merged

test: add comprehensive unit tests for src/utils/index.ts#31
GoBeromsu merged 1 commit into
masterfrom
test/utils-index-unit-tests

Conversation

@GoBeromsu

Copy link
Copy Markdown
Owner

Summary

  • Added 38 comprehensive unit tests for src/utils/index.ts
  • Achieves 100% code coverage across all metrics (statements, branches, functions, lines)
  • All tests follow existing patterns with Jest and descriptive naming conventions

Test Coverage

PROVIDER_NAMES (3 tests)

  • Validates all 8 provider constants match JSON data
  • Verifies correct provider name values
  • Tests constant immutability

generateId() (4 tests)

  • Returns a number type
  • Returns current timestamp
  • Generates unique/increasing IDs
  • Handles async ID generation

getProviderPresets() (5 tests)

  • Returns array of presets
  • Contains all 8 expected providers
  • Each preset has required ProviderPreset properties
  • Excludes apiKey property correctly

getProviderPreset() (12 tests)

  • Successfully retrieves each of 8 providers by name
  • Throws descriptive errors for non-existent providers
  • Case-sensitive name matching
  • Validates popularModels structure

findMatchingPreset() (14 tests)

  • Matches by exact baseUrl
  • Matches by exact name
  • Prioritizes baseUrl over name
  • Returns 'Custom Provider' for non-matches
  • Tests all providers
  • Case-sensitive matching
  • No partial URL matching

Test Results

Test Suites: 1 passed, 1 total
Tests:       38 passed, 38 total
Coverage:    100% (Statements, Branches, Functions, Lines)

Test Plan

  • All new tests pass
  • Existing tests still pass (113 total)
  • 100% code coverage achieved
  • Tests follow existing patterns in codebase
  • Descriptive test names and organized with describe blocks
  • Tests cover edge cases and error conditions

🤖 Generated with Claude Code

Add 38 comprehensive unit tests covering all exported functions and constants:
- PROVIDER_NAMES: Validate all 8 provider constants match JSON data
- generateId(): Test ID generation, uniqueness, and timestamp behavior
- getProviderPresets(): Test array return and ProviderPreset structure
- getProviderPreset(): Test all providers and error handling
- findMatchingPreset(): Test matching by baseUrl, name, and fallback logic

Achieves 100% code coverage (statements, branches, functions, lines).
All tests follow existing patterns with Jest and descriptive test names.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@GoBeromsu
GoBeromsu merged commit ac9a7f2 into master Dec 28, 2025
1 check passed
@GoBeromsu
GoBeromsu deleted the test/utils-index-unit-tests branch December 28, 2025 11:42
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