fix: make all tests pass — implement missing utilities and fix edge-case bugs - #287
Open
stooit wants to merge 1 commit into
Open
fix: make all tests pass — implement missing utilities and fix edge-case bugs#287stooit wants to merge 1 commit into
stooit wants to merge 1 commit into
Conversation
…ests - calculator: divide now throws on division by zero instead of returning Infinity - string-utils: fix wordCount whitespace splitting; implement truncate with word-boundary + ellipsis budget - task-manager: implement remove, update, and sortBy methods - date-utils: fix off-by-one in formatRelative day bucketing (round vs floor) - validator: accept long TLDs in isEmail; accept port-bearing 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 failing tests across the utility library (60/60 pass, previously 44/60). Only source files under
src/were changed — no test files edited, no dependencies added, per the task constraints.Changes
src/calculator.ts—dividenow throws on division by zero instead of silently returningInfinity.src/string-utils.ts—wordCountsplits on/\s+/(handles consecutive spaces, tabs, newlines); implementedtruncatewith word-boundary cutting and an ellipsis budget so output never exceedsmaxLength.src/task-manager.ts— implemented the missingremove,update, andsortBymethods.sortByuses typed rank maps (high > medium > low) and ascendingcreatedAt(oldest first).src/date-utils.ts— fixed off-by-one informatRelativeday bucketing (Math.roundinstead ofMath.floor);Math.absmoved before rounding so past/future dates stay symmetric.src/validator.ts—isEmailaccepts long TLDs (e.g..museum);isUrlaccepts port-bearing URLs (e.g.http://localhost:3000) while keeping the protocol allowlist (rejectsftp:,javascript:,data:).Verification
bun test→ 60 pass / 0 failtsc --noEmit(strict) → cleanNotes & assumptions
NaNmaxLengthguards intruncate, a runtimedefaultinsortBy, ability to clear optional fields inupdate) — all outside the test requirements and left as-is to avoid scope creep.isUrlis now port-agnostic (http://localhost:3000,http://[::1]:8080pass), so it must not be relied on as an SSRF/open-redirect allowlist.isEmailremains a structural check, not RFC 5322 validation or proof of deliverability.