fix: repair edge-case bugs and implement missing utility functions - #271
Open
stooit wants to merge 1 commit into
Open
fix: repair edge-case bugs and implement missing utility functions#271stooit 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: wordCount collapses consecutive whitespace; implement truncate with word-boundary logic and ellipsis counting toward maxLength - task-manager: implement remove, update, and sortBy methods - date-utils: fix formatRelative off-by-one via symmetric magnitude rounding - validator: relax isEmail TLD length and accept host-only/ported URLs in isUrl Fixes 16 failing tests (44 -> 60 pass). No test files or dependencies changed.
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 in the utility library (44 → 60 pass / 0 fail). Only the 5 source files were changed — no test files modified, no dependencies added, clean
tsc --noEmit.Changes
calculator.ts—dividenow throws on division by zero instead of returningInfinity.string-utils.ts—wordCountcollapses consecutive whitespace ("hello world"→ 2); implementedtruncatewith word-boundary logic where"..."counts towardmaxLength, returning the string unchanged when within the limit and handlingmaxLength <= 3without exceeding it.task-manager.ts— implementedremove(returns true/false),update(title/description/priority, returns true/false), andsortBy(priority high > medium > low, pluscreatedAt/status, relying on stable sort for insertion-order tiebreaks).date-utils.ts— fixedformatRelativeoff-by-one: 36h ago now rounds to "2 days ago"; rounding applied on the magnitude so past/future are symmetric.validator.ts—isEmailaccepts long TLDs (e.g..museum);isUrlaccepts host-only and ported URLs (e.g.http://localhost:3000).Verification
bun test→ 60 pass / 0 fail (70 expect() calls)npx tsc --noEmit→ cleanAssumptions
truncatespec (word boundary, ellipsis-in-budget) inferred from the test file's expected values and the source TODO comment.sortBypriority ordering (high > medium > low) taken from the test expectations.