Skip to content

fix: make all failing tests pass across utility library - #283

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2212-1786516665
Open

fix: make all failing tests pass across utility library#283
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2212-1786516665

Conversation

@stooit

@stooit stooit commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously failing tests (60/60 now green) across the TypeScript utility library. Only src/ files changed — no test files modified, no new dependencies.

Changes

  • src/calculator.tsdivide now throws on a zero divisor instead of returning Infinity (explicit b === 0 guard, also catches -0).
  • src/string-utils.ts — implemented truncate (ellipsis counted within maxLength, word-boundary aware); fixed wordCount to split on /\s+/ so runs of whitespace/tabs/newlines don't produce phantom empty words.
  • src/task-manager.ts — implemented stubbed remove, update (partial updates only touch provided keys), and sortBy (priority/status rank maps + createdAt timestamp; sorts a copy).
  • src/date-utils.tsformatRelative day calc uses Math.round instead of Math.floor, so 36h reads "2 days ago".
  • src/validator.tsisEmail accepts long TLDs (e.g. .museum) while still rejecting empty labels; isUrl no longer rejects URLs with ports (e.g. http://localhost:3000), protocol still allowlisted to http/https.

Verification

  • bun test → 60 pass / 0 fail (stable across repeated runs)
  • tsc --noEmit clean
  • Independent review pass: no over-fitting to individual assertions; each fix generalises past its test. Verdict: safe to commit.

Assumptions & notes

  • divide throwing is an API-visible behaviour change vs. the previous Infinity return, sanctioned by the in-code BUG: comment.
  • Two edge cases outside current test coverage were noted for possible follow-up (non-blocking): negative maxLength in truncate, and clearing an optional description field via update.
  • isUrl/isEmail are syntactic validators only; if isUrl ever guards a redirect/fetch target, protocol allowlisting alone won't prevent SSRF to internal addresses.

Implements truncate, TaskManager remove/update/sortBy; fixes wordCount
consecutive-space handling, formatRelative day rounding, isEmail long
TLDs, and isUrl port rejection.
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