Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2486-1784996727
Open

fix: implement missing utilities and fix edge-case bugs#262
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2486-1784996727

Conversation

@stooit

@stooit stooit commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes all 16 previously-failing tests pass while keeping the existing 44 green (60/60 pass). Fixes were limited to source files only — no test files or dependencies were touched.

Changes by file

  • src/calculator.tsdivide now throws Error("Division by zero") when the divisor is 0.
  • src/string-utils.ts — implemented truncate (word-boundary truncation with the "..." ellipsis counted toward maxLength, plus a fallback when maxLength <= 3); fixed wordCount to collapse multiple consecutive spaces.
  • src/task-manager.ts — implemented remove (returns false for unknown id), update (in-place update, false for unknown id), and sortBy for createdAt (oldest first) and priority (high → medium → low).
  • src/date-utils.ts — fixed off-by-one in formatRelative by rounding rather than flooring the day delta (36h now reads as "1 day ago").
  • src/validator.tsisEmail now accepts subdomains and long TLDs (e.g. .museum); isUrl rewritten to use the standard URL constructor so ports (e.g. http://localhost:3000) validate correctly.

Verification

  • bun test60 pass, 0 fail.
  • Independent review pass: all fixes confirmed correct and general (not test-narrow), no regressions.

Assumptions

  • update restricts mutable fields to title/priority to match TaskManager semantics.
  • sortBy copies before sorting so the internal store order is not mutated.

- calculator: guard divide against division by zero
- string-utils: implement truncate (word-boundary + ellipsis) and fix wordCount for consecutive spaces
- task-manager: implement remove, update, and sortBy
- date-utils: fix off-by-one in formatRelative (round instead of floor)
- validator: fix isEmail for long TLDs/subdomains and isUrl for ports (use URL constructor)
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