fix: resolve all failing tests across utility modules#229
Open
stooit wants to merge 1 commit into
Open
Conversation
- calculator: divide now throws on division by zero instead of returning Infinity - date-utils: diffDays uses Math.round so 36h rounds to 2 days - string-utils: implement word-boundary truncate and fix wordCount on consecutive spaces - task-manager: implement remove(), update(), and sortBy() - validator: isEmail accepts subdomains and 2+ char TLDs; isUrl accepts URLs with ports
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 utility library. 60/60 tests now pass, with no previously-passing test broken. Changes are scoped to
src/only — no test files modified, no dependencies added.Changes by module
calculator.ts—dividenow throwsError("Division by zero")when the divisor is0(previously returnedInfinity).date-utils.ts—diffDaysusesMath.roundinstead ofMath.floor, fixing the off-by-one so 36 hours correctly reports "2 days ago".string-utils.ts— implemented word-boundarytruncate(ellipsis counts towardmaxLength, handles strings shorter than the ellipsis, returns unchanged when within limit); fixedwordCountto collapse multiple consecutive spaces.task-manager.ts— implemented the missing/incompleteremove(),update(), andsortBy()(priority high→medium→low, andcreatedAtoldest-first) methods.validator.ts—isEmailregex now accepts subdomains and 2+ character TLDs (e.g.user@example.museum);isUrlaccepts URLs with ports (e.g.http://localhost:3000). Stale comment updated to reflect current behaviour.Testing
bun test→ 60 pass / 0 fail (70 expect() calls).Assumptions
diffDaysrounding to nearest day is the intended relative-time behaviour.Review
Reviewed by the review subagent (verdict: ship). Implementations are genuine fixes, not test-gaming hacks.