Skip to content

Add comprehensive unit tests for managers/common/utils.ts utility functions#7

Closed
Copilot wants to merge 4 commits intomainfrom
copilot/write-complex-tests
Closed

Add comprehensive unit tests for managers/common/utils.ts utility functions#7
Copilot wants to merge 4 commits intomainfrom
copilot/write-complex-tests

Conversation

Copy link
Copy Markdown

Copilot AI commented Dec 3, 2025

Added 97 unit tests covering 8 utility functions in managers/common/utils.ts, focusing on edge cases and complex scenarios including cross-platform behavior, malformed inputs, and boundary conditions.

Functions Tested

  • isNumber() (12 tests) - NaN/Infinity handling, type coercion edge cases
  • shortVersion() (11 tests) - Version string parsing with malformed inputs, leading zeros, multi-digit segments
  • isGreater() (14 tests) - Version comparison with undefined values, varying segment lengths, non-numeric parts
  • compareVersions() (12 tests) - Semantic versioning with missing segments, triple-digit parts
  • sortEnvironments() (9 tests) - Multi-criteria sorting (version → name → path), undefined version handling
  • getLatest() (10 tests) - Empty arrays, version ties, undefined values
  • mergePackages() (13 tests) - Deduplication logic, large datasets, property preservation
  • pathForGitBash() (16 tests) - Cross-platform path conversion, UNC paths, special characters

Example Test Coverage

// Edge case: isNumber correctly rejects NaN (unlike typeof)
test('returns false for NaN', () => {
    assert.strictEqual(isNumber(NaN), false);
});

// Complex scenario: sortEnvironments with mixed versions and names
const envs = [
    createEnv('venv', '3.9.0', '/z/venv'),
    createEnv('conda', '3.11.0', '/a/conda'),
    createEnv('venv', '3.11.0', '/a/venv'),
];
const sorted = sortEnvironments(envs);
// Correctly sorts by version desc → name asc → path asc

Note

getShellActivationCommands() tests omitted - function requires file system mocking which is non-trivial with fs-extra's non-configurable properties. Better suited for integration testing.

Original prompt

write tests for this class and its functions- focus on more complex scenarios and edge cases as we want to keep these tests really useful

Created from VS Code.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Copilot AI changed the title [WIP] Add tests for class functions with edge cases Add comprehensive unit tests for managers/common/utils.ts utility functions Dec 3, 2025
Copilot AI requested a review from eleanorjboyd December 3, 2025 20:39
@eleanorjboyd eleanorjboyd deleted the copilot/write-complex-tests branch December 15, 2025 22:28
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.

2 participants