fix: implement missing utilities and fix edge-case test failures - #322
Open
stooit wants to merge 1 commit into
Open
fix: implement missing utilities and fix edge-case test failures#322stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
- calculator.divide: throw on division by zero (incl. -0 and 0/0) - string-utils.wordCount: stop over-counting consecutive spaces - string-utils.truncate: implement word-boundary truncation with ellipsis counting toward maxLength - task-manager: implement remove, update, and sortBy (priority + createdAt) - date-utils.formatRelative: fix off-by-one at the 36h boundary - validator.isEmail/isUrl: accept valid long TLDs and URLs with ports All 60 tests pass; no test files or dependencies modified.
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 across the utility library.
bun testnow reports 60 pass / 0 fail, andtsc --noEmitis clean. No test files were modified and no dependencies were added.Changes
calculator.divide— throws on division by zero (including-0and0/0).string-utils.wordCount— no longer over-counts on multiple consecutive spaces.string-utils.truncate— implemented per the TODO: truncates at a word boundary, with"..."counting towardmaxLength; returns the string unchanged whenstr.length <= maxLength; degrades to a hard cut whenmaxLength <= 3. Length invariant verified by fuzzing.task-manager(TaskManager) — implementedremove(returnsfalsefor unknown id),update(partial updates, returnsfalsefor unknown id, only touches keys explicitly present), andsortByforpriority(high > medium > low) andcreatedAt(oldest first, returns a copy).date-utils.formatRelative— fixed off-by-one at the 36h boundary (now "2 days ago").validator.isEmail/isUrl— accept valid long TLDs and URLs with a port; protocol allowlist retained (javascript:/data:/file:still reject).Verification
bun test-> 60 pass / 0 failbunx tsc --noEmit-> cleanAssumptions
Follow-ups (out of scope, non-blocking — flagged by review)
isEmaillocal part still uses[^\s@]+, accepting control chars / injection-adjacent payloads (pre-existing).isUrlaccepts embedded credentials (https://example.com@evil.com/); consider rejecting username/password if used to gate redirects/fetches.README.mdstill advertises the now-fixed defects.