fix: repair all failing tests in utility library - #258
Open
stooit wants to merge 1 commit into
Open
Conversation
- calculator: throw on division by zero instead of returning Infinity - string-utils: fix wordCount whitespace splitting; implement truncate with word-boundary and small-maxLength handling - task-manager: implement remove, update, and sortBy methods - date-utils: use Math.round for relative day rounding (36h -> 2 days) - validator: allow TLDs >4 chars in isEmail; simplify isUrl to protocol check
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 TypeScript utility library. All 60 tests now pass (0 fail), and no previously-passing tests were broken. No test files were modified and no dependencies were added.
Changes by file
dividenow throwsError("Division by zero")instead of returningInfinity.wordCountnow splits on/\s+/(handles multiple/leading/trailing spaces); implementedtruncatewith word-boundary trimming, and correct handling whenmaxLength <= 3(slices tomaxLengthrather than returning the full string).remove(returns boolean),update(returns boolean,Object.assignof changes), andsortBy(priority weight map,createdAtascending, status vialocaleCompare).formatRelativeusesMath.roundinstead ofMath.floorfor the days bucket (36h now rounds to "2 days ago").isEmailTLD quantifier relaxed from{2,4}to{2,}(allows TLDs like.museum);isUrlnow checks only that the protocol is http/https.Verification
bun test→ 60 pass / 0 fail.Assumptions
truncate's ellipsis is the literal"..."(3 chars) counted withinmaxLength.sortBy("createdAt")sorts oldest-first; unknown field falls back to status ordering.