fix: repair failing utility tests and implement missing functionality#237
Open
stooit wants to merge 1 commit into
Open
fix: repair failing utility tests and implement missing functionality#237stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- calculator: divide now throws on division by zero instead of returning Infinity - string-utils: fix wordCount for consecutive spaces; implement word-boundary truncate with ellipsis - task-manager: implement remove, update, and sortBy (priority/createdAt) - date-utils: fix formatRelative rounding so 36h reads '2 days ago' and no '24 hours ago' output - validator: accept long TLDs in isEmail and host:port URLs in isUrl
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 the utility library. The full suite now passes: 60 pass, 0 fail. No test files were modified and no dependencies were added.
Changes by module
src/calculator.ts—dividenow throws on division by zero instead of returningInfinity.src/string-utils.ts—wordCounthandles multiple consecutive spaces (trim + split on\s+);truncateimplemented to respect word boundaries with the ellipsis counting towardmaxLengthand handling strings shorter than the ellipsis.src/task-manager.ts— implemented/completedremove(returnsfalsefor unknown id),update(title/priority, returnsfalsefor unknown id), andsortByforpriority(high → medium → low) andcreatedAt(oldest first).src/date-utils.ts— fixedformatRelativerounding so 36 hours reads "2 days ago"; the rounded hour value now drives both the< 24branch guard and the label, so "24 hours ago" can no longer be emitted.src/validator.ts—isEmailaccepts long TLDs (e.g..museum);isUrlacceptshost:portURLs (e.g.http://localhost:3000).Verification
bun test→ 60 pass, 0 fail, 70 expect() calls.src/*.tsfiles changed; no test files touched.Review notes
Changes were reviewed by a review pass; follow-up polish applied: made the hours/days boundary consistent, fixed a
lastSpace >= 0boundary case intruncate, and removed staleBUG:/TODO:comments.Assumptions