Skip to content

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

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2195-1787869704
Open

fix: implement missing utilities and fix edge-case bugs#306
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2195-1787869704

Conversation

@stooit

@stooit stooit commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously failing tests across the utility library (now 60 pass / 0 fail). Only source files were modified — no test files touched, no dependencies added.

Changes

  • calculatordivide now throws on division by zero instead of silently returning Infinity.
  • string-utilswordCount collapses consecutive whitespace (splits on /\s+/); implemented truncate to cut at a word boundary with "..." counting toward maxLength, returning the string unchanged when within limit.
  • task-manager — implemented the previously unimplemented remove, update, and sortBy methods (priority: high > medium > low; createdAt: oldest first; status ordering).
  • date-utils — fixed off-by-one in formatRelative (Math.round instead of Math.floor); 36 hours ago now reads "2 days ago".
  • validatorisEmail accepts long alphabetic TLDs (e.g. .museum); isUrl accepts URLs with an explicit port (e.g. http://localhost:3000).

Testing

bun test60 pass, 0 fail. tsc --noEmit clean.

Assumptions

  • truncate hard-slices when maxLength <= 3 (no room for content + ellipsis), and only walks back to a word boundary when the cut lands mid-word.
  • update guards each field against undefined so a partial change object cannot blank out existing values.
  • sortBy relies on Array.prototype.sort stability to preserve insertion order for equal keys.

Note (out of test scope, not changed)

isEmail is a syntactic check only — it does not prove deliverability or ownership. If any caller gates account creation on it, that should be backed by a confirmation-link flow.

- calculator: divide now throws on division by zero instead of returning Infinity
- string-utils: fix wordCount to collapse consecutive whitespace; implement truncate at word boundary with ellipsis counting toward maxLength
- task-manager: implement remove, update, and sortBy methods
- date-utils: fix off-by-one in formatRelative (Math.round instead of Math.floor)
- validator: allow long TLDs in isEmail; accept URLs with ports in isUrl

All 60 tests pass.
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