Skip to content

fix: resolve all failing tests in utility library#241

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2484-1783443255
Open

fix: resolve all failing tests in utility library#241
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2484-1783443255

Conversation

@stooit

@stooit stooit commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across the TypeScript utility library. The full suite now passes 60/60 (was 44 pass / 16 fail). No test files were modified and no dependencies were added — only source fixes required by the tests.

Changes by file

  • src/calculator.tsdivide now throws on division by zero instead of returning Infinity.
  • src/date-utils.tsformatRelative uses Math.round (was Math.floor) for the hours→days conversion, fixing the off-by-one at the 36-hour boundary (now "2 days ago").
  • src/string-utils.ts — implemented truncate (respects word boundaries, counts the ellipsis toward maxLength, handles strings shorter than the ellipsis) and fixed wordCount to split on \s+ so consecutive spaces don't inflate the count.
  • src/task-manager.ts — implemented the missing/incomplete remove, update, and sortBy methods (sortBy orders priority high>medium>low and createdAt oldest-first; remove/update return false for unknown ids).
  • src/validator.tsisEmail accepts subdomains and long TLDs; isUrl accepts URLs with ports. Also refreshed a stale JSDoc comment.

Verification

  • bun test → 60 pass, 0 fail, 70 expect() calls.
  • Reviewed by the review subagent: fixes are general-purpose (not hard-coded to test inputs), no regressions.

Assumptions

  • The intended behaviour was inferred from the existing (unmodified) tests, which were treated as the source of truth per the task brief.

- calculator: throw on division by zero instead of returning Infinity
- date-utils: use Math.round for relative-day calc (fix 36h off-by-one)
- string-utils: implement truncate (word-boundary + ellipsis budget) and fix wordCount for consecutive spaces
- task-manager: implement remove, update, and sortBy methods
- validator: allow subdomains and long TLDs in isEmail, fix isUrl for ports
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant