fix(utils): resolve 16 failing tests across the utility library - #328
Open
stooit wants to merge 1 commit into
Open
fix(utils): resolve 16 failing tests across the utility library#328stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
…manager, date, and validator utils - calculator.divide: throw on division by zero instead of returning Infinity - string-utils.wordCount: split on whitespace runs (handles multiple spaces/tabs/newlines) - string-utils.truncate: implement word-boundary truncation with ellipsis counted toward maxLength - task-manager: implement remove/update return semantics and sortBy (priority, status, createdAt) - date-utils.formatRelative: round days (and symmetric future/past) so 36h reads as 2 days - validator: isEmail accepts multi-label domains/long TLDs; isUrl accepts explicit ports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all 16 previously-failing tests across 5 source files. Suite is now 60 pass / 0 fail,
tsc --noEmitclean. No test files modified, no dependencies added.Changes
calculator.ts—dividethrows on division by zero (was returningInfinity).string-utils.ts—wordCountsplits on whitespace runs (fixes multiple spaces/tabs/newlines);truncateimplemented (word-boundary cut,"..."counted towardmaxLength, returns input unchanged when within limit).task-manager.ts—remove/updatereturn correct booleans for known/unknown ids and apply partial updates safely;sortByranks priority (high→medium→low), status (pending→in_progress→completed), and orderscreatedAtoldest-first.date-utils.ts—formatRelativerounds days (36h → "2 days ago"); future/past now symmetric.validator.ts—isEmailaccepts multi-label domains and long TLDs;isUrlaccepts URLs with explicit ports (protocol allowlist unchanged, still http/https only).Assumptions
truncate/formatRelative(symmetric future dates; trailing-space trim on truncate).Review notes (non-blocking, not required by tests)
A review pass confirmed no regressions and cleared
formatRelativesymmetry,isEmailReDoS safety, andisUrl/task-managercorrectness. It flagged 3 minor edge cases in the newtruncatecode, none exercised by the test suite and none merge-blocking:slicecan split UTF-16 surrogate pairs (emoji) → lone surrogate."...".maxLength <= 3the ellipsis marker is dropped (hard cut).Left as follow-ups to honour the "fix only what the tests require" constraint. Also noted:
isEmail/isUrlare format checks, not input sanitisation.🤖 Generated with QuantCode