Skip to content

Add unit tests for maskApiKey edge cases #152

Description

@404-Page-Found

Description

The maskApiKey function in src/commands/config.ts masks stored API keys for display. It has a visibleLength calculation (Math.min(4, Math.max(2, apiKey.length))) that handles short and long keys differently, but no unit tests exercise this function directly.

Proposed Solution

Tests should cover:

  • undefined returns 'not stored in config'
  • Empty string returns 'not stored in config'
  • A 1-character key returns 2 visible characters (due to Math.max(2, ...))
  • A 2-character key returns the full key + dots
  • A 3-character key returns the full key + dots
  • A 4+ character key shows first 4 characters + dots

Why It is a Good First Issue

Pure function with clear edge cases. The test file tests/config-command.test.mjs already imports from dist/commands/config.js and has the test infrastructure.

Files

  • src/commands/config.ts (lines 10-17)
  • tests/config-command.test.mjs

Metadata

Metadata

Assignees

Type

No fields configured for Task.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions