Skip to content

fix: repair failing tests across utility library - #339

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2172-1789143549
Open

fix: repair failing tests across utility library#339
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2172-1789143549

Conversation

@stooit

@stooit stooit commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across 5 modules. Test suite now: 60 pass, 0 fail. Typecheck clean (tsc --noEmit).

Changes

File Change
src/calculator.ts divide throws Error("Division by zero") when divisor is 0 instead of returning Infinity.
src/string-utils.ts wordCount trims and splits on /\s+/ (fixes consecutive-space over-count); implemented truncate to cut at the last word boundary within maxLength - 3 and append "...".
src/task-manager.ts Implemented remove, update (applies only defined fields, returns false if not found), and sortBy (priority, status, and createdAt).
src/date-utils.ts diffDays uses Math.round instead of Math.floor, fixing the off-by-one in relative-date rendering.
src/validator.ts isEmail accepts subdomains and longer TLDs; isUrl no longer rejects URLs that specify a port.

Constraints honoured

  • No test files modified.
  • No new dependencies added.
  • Minimal, test-driven fixes only.

Assumptions & notes for reviewers

  • isUrl is a format check, not an SSRF control. It now accepts any host/port including localhost, RFC1918 addresses and 169.254.169.254. Correct for the tests, but if this is ever used to validate a URL the server will fetch (webhooks/callbacks), it needs a separate resolved-host allowlist (OWASP SSRF; ISM-1685).
  • sortBy("createdAt") relies on Array.prototype.sort stability for same-millisecond ties (guaranteed since ES2019). No explicit tiebreaker added, as tests don't require it.

…ation edge cases

- calculator: divide throws on division by zero instead of returning Infinity
- string-utils: wordCount handles consecutive spaces; implement truncate at word boundary
- task-manager: implement remove, update, and sortBy methods
- date-utils: diffDays uses Math.round to fix off-by-one in relative dates
- validator: isEmail accepts subdomains/long TLDs; isUrl permits 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