fix: repair failing utility tests and implement missing functions - #318
Open
stooit wants to merge 1 commit into
Open
fix: repair failing utility tests and implement missing functions#318stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- calculator: divide throws on zero divisor instead of returning Infinity - validator: isEmail accepts long TLDs (.museum); isUrl accepts URLs with ports - date-utils: round day diff so 36h reads as 2 days (off-by-one fix) - string-utils: wordCount collapses runs of whitespace; implement truncate (ellipsis counts toward maxLength, cuts at word boundary, no content loss on leading whitespace) - task-manager: implement remove/update/sortBy (priority + createdAt ordering)
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 failing tests (now 60/60 pass) by repairing edge-case bugs and implementing missing functions across the utility library. No test files modified, no dependencies added — only
src/touched.Changes
dividenow throws on a zero divisor instead of silently returningInfinity(also catches-0).isEmailaccepts long TLDs (e.g..museum) with a 254-char length guard;isUrlno longer rejects URLs with a port (e.g.http://localhost:3000) while still allow-listing http(s).wordCountcollapses runs of whitespace (spaces/tabs/newlines);truncateimplemented so the ellipsis counts towardmaxLength, cuts at a word boundary, and never returns content-free output (including on leading whitespace).remove(returns removed/not-found bool),update(applies only present keys; required fields ignore explicitundefined, optionaldescriptioncan be cleared), andsortBy(priority high>medium>low, createdAt oldest-first; returns a sorted copy leaving internal order intact).Verification
bun test→ 60 pass / 0 failtsc --noEmit→ cleanAssumptions
sortBy("status")is not covered by any test; orderedin_progress > pending > completed(active work first). Documented as a judgement call — worth confirming intent.