Tests: Missing direct unit test coverage for isHandle() in wporg-handle.cjs

Open Beginner friendly
#484 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
1-3 hours
Newbie friendliness
92/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript
Domain
testing

Research direction

Start in src/wporg-handle.cjs to inspect the exported isHandle(value), then open tests/unit/wporg-handle.test.cjs and follow the existing parseHandle and handoffFilename test style. Import isHandle directly, cover the listed valid and invalid inputs plus length boundaries, and run the unit test file to confirm the complete contract is exercised.

Written by the indexing model from the issue text.

Description

Description

src/wporg-handle.cjs exports isHandle(value) to determine whether a value is already a canonical WordPress.org handle before using it in structural positions (such as patch filenames in src/patch-provenance.cjs).

Currently, tests/unit/wporg-handle.test.cjs does not import or test isHandle(value) directly. While parseHandle and handoffFilename have test coverage, isHandle itself lacks dedicated unit tests verifying its exact contract:

  • Valid canonical handles (letters, digits, valid internal separators _, -, .).
  • Strict lowercase requirement (JaneDoe must return false).
  • Length boundaries (MAX_HANDLE_LENGTH = 60 returns true, 61 returns false).
  • Refusal of leading/trailing separators (-janedoe, janedoe-, .janedoe, janedoe_).
  • Refusal of invalid characters (spaces, slashes, path traversal, newlines, #).
  • Refusal of non-string or empty inputs (null, undefined, numbers, objects, arrays, empty strings).
Proposed Solution

Add dedicated unit tests in tests/unit/wporg-handle.test.cjs to cover all criteria of isHandle().

Dominant language
JavaScript
Stars
36
Forks
13
Avg merge
14h 42m
Merged PRs (30d)
70

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from WordPress/contributor-toolkit

All issues in WordPress/contributor-toolkit

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.