Skip to content

fix: implement missing utilities and fix edge-case bugs#215

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2464-1781632182
Open

fix: implement missing utilities and fix edge-case bugs#215
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2464-1781632182

Conversation

@stooit

@stooit stooit commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes all failing tests pass in the TypeScript utility library. The suite went from 44/60 → 60/60 passing, with no test files modified and no new dependencies added.

Changes by file

  • src/calculator.tsdivide() now throws "Division by zero" instead of returning Infinity.
  • src/string-utils.tswordCount() collapses consecutive whitespace (trim().split(/\s+/)); truncate() implemented with word-boundary truncation, ellipsis counted toward maxLength, and explicit handling for tiny/zero maxLength.
  • src/task-manager.ts — implemented remove(), update(), and sortBy() (priority: high→medium→low; createdAt: oldest first). update() uses explicit per-key assignment so callers can't silently overwrite status/completedAt.
  • src/date-utils.tsformatRelative() off-by-one fixed (rounds instead of floors, so 36h reads as "2 days ago").
  • src/validator.tsisEmail() accepts long TLDs; isUrl() accepts URLs with a port.

Verification

  • bun test60 pass, 0 fail (70 assertions).
  • No files under test/ changed.

Assumptions

  • Followed the behaviour encoded in the existing tests as the spec (e.g. division-by-zero throws; relative-time rounds).
  • Applied a few low-risk hardening tweaks surfaced in review (explicit update guards, degenerate truncate input handling, stale BUG: comment cleanup) — all kept the suite green.

- calculator.divide: throw on division by zero instead of returning Infinity
- string-utils.wordCount: collapse consecutive whitespace; truncate: implement word-boundary truncation with ellipsis accounting
- task-manager: implement remove/update/sortBy; guard update() against overwriting status/completedAt
- date-utils.formatRelative: fix off-by-one (round, not floor)
- validator.isEmail/isUrl: handle long TLDs and URLs with ports

All 60 tests pass (was 44/60).
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