fix: repair 16 failing tests across utility library - #310
Open
stooit wants to merge 1 commit into
Open
Conversation
- calculator: divide throws on division by zero instead of returning Infinity - string-utils: wordCount collapses whitespace runs; implement truncate at word boundary with ellipsis counting toward maxLength - task-manager: implement remove, update, and sortBy (priority high>medium>low, createdAt oldest-first) - date-utils: formatRelative rounds hours (Math.round) fixing 36h off-by-one - validator: isEmail accepts long TLDs; isUrl accepts URLs with 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. 60/60 tests pass,
tsc --noEmitclean. No test files modified, no dependencies added.Fixes
dividenow throws on division by zero instead of returningInfinity.wordCountcollapses consecutive-whitespace runs (/\s+/); implementedtruncateto cut at a word boundary with"..."counting towardmaxLength, returning the string unchanged when within limit.remove(true/false on found),update(title/description/priority, true/false on found), andsortBy(priority high>medium>low, createdAt oldest-first, plus status ordering).formatRelativeoff-by-one fixed by rounding hours-to-days (Math.round), so 36h → "2 days ago"; symmetry preserved for future dates.isEmailaccepts long TLDs (e.g..museum) while still rejectinga@b..com;isUrlaccepts URLs with ports (e.g.http://localhost:3000).Verification
bun test: 60 pass, 0 failtsc --noEmit: cleanAssumptions
sortBy("status")order (in_progress > pending > completed) and the numericidtiebreak for same-millisecondcreatedAtties are not exercised by tests; chosen as reasonable defaults.updateclearing optional fields, SSRF/credential-URL considerations forisUrl) that go beyond what the tests require; left out per the "fix only what the tests require" constraint.