Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2489-1782879814
Open

fix: implement missing utilities and fix edge-case bugs#234
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2489-1782879814

Conversation

@stooit

@stooit stooit commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across the utility library. All 60 tests now pass with no regressions and no test files modified.

Changes

  • src/calculator.tsdivide now throws Error("Division by zero") when the divisor is 0.
  • src/date-utils.tsformatRelative uses Math.round (was Math.floor) for the day difference, fixing the off-by-one so 36 hours reports as 2 days.
  • src/validator.ts
    • isEmail accepts TLDs longer than 4 characters (e.g. .museum).
    • isUrl validates via the URL constructor, correctly handling ports, paths, and query strings.
  • src/string-utils.ts
    • wordCount splits on runs of whitespace and ignores empty tokens.
    • truncate truncates at a word boundary with the ellipsis counted toward maxLength, and handles strings shorter than the ellipsis.
  • src/task-manager.ts — implemented/completed remove, update, and sortBy (priority high→medium→low, createdAt oldest-first).

Testing

bun test60 pass / 0 fail.

Assumptions

  • Scope limited to what the tests require; broader edge cases not covered by tests were left unchanged.
  • No new dependencies added; no test files modified.

…ests

- calculator.divide: throw on division by zero
- date-utils.formatRelative: use Math.round for day diff (36h -> 2 days)
- validator.isEmail: allow TLDs longer than 4 chars
- validator.isUrl: parse via URL constructor (handles ports/paths/queries)
- string-utils.wordCount: split on whitespace runs, ignore empties
- string-utils.truncate: word-boundary truncation with ellipsis in budget
- task-manager: implement remove, update, and sortBy (priority, createdAt)
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