WordPress / WordPress/contributor-toolkit
Tests: Missing direct unit test coverage for isHandle() in wporg-handle.cjs
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 36
- Forks
- 13
- Avg merge
- 23h 19m
- Merged PRs (30d)
- 72
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 (
JaneDoemust returnfalse). - Length boundaries (
MAX_HANDLE_LENGTH = 60returnstrue,61returnsfalse). - 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().
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
Assessment
- Tech stack
- javascript
- Domain
- testing
- Issue type
- Refactor
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 92/100