Skip to content

fix: resolve all failing tests across utility library#183

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/job-e2e-tier1-2340-1779902193
Open

fix: resolve all failing tests across utility library#183
stooit wants to merge 1 commit into
mainfrom
quantcode/job-e2e-tier1-2340-1779902193

Conversation

@stooit
Copy link
Copy Markdown
Contributor

@stooit stooit commented May 27, 2026

Summary

  • calculator.ts: divide now throws Error("Division by zero") when divisor is 0 instead of returning Infinity
  • string-utils.ts: Fixed wordCount to split on /\s+/ regex (handles multiple consecutive spaces); implemented truncate with word-boundary-aware truncation and "..." suffix
  • task-manager.ts: Implemented missing remove, update, and sortBy methods
  • date-utils.ts: Changed formatRelative day calculation from Math.floor to Math.round to fix off-by-one error
  • validator.ts: Fixed isEmail regex to allow TLDs of 2+ characters; fixed isUrl regex to allow optional port numbers

Test Results

All 60 tests pass (previously 44 pass / 16 fail).

Assumptions

  • truncate truncates at word boundaries when possible, falling back to hard truncation when no boundary fits within the limit
  • sortBy("priority") orders high > medium > low
  • sortBy("createdAt") orders oldest first
  • sortBy("status") orders alphabetically (done < in-progress < todo)

- calculator: throw Error on division by zero instead of returning Infinity
- string-utils: fix wordCount to handle multiple consecutive spaces, implement truncate
- task-manager: implement remove, update, and sortBy methods
- date-utils: use Math.round instead of Math.floor for day calculation
- validator: allow long TLDs in email validation, allow ports in URL validation
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