Skip to content

fix(utils): resolve 16 failing tests across the utility library - #328

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2160-1788936491
Open

fix(utils): resolve 16 failing tests across the utility library#328
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2160-1788936491

Conversation

@stooit

@stooit stooit commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 previously-failing tests across 5 source files. Suite is now 60 pass / 0 fail, tsc --noEmit clean. No test files modified, no dependencies added.

Changes

  • calculator.tsdivide throws on division by zero (was returning Infinity).
  • string-utils.tswordCount splits on whitespace runs (fixes multiple spaces/tabs/newlines); truncate implemented (word-boundary cut, "..." counted toward maxLength, returns input unchanged when within limit).
  • task-manager.tsremove/update return correct booleans for known/unknown ids and apply partial updates safely; sortBy ranks priority (high→medium→low), status (pending→in_progress→completed), and orders createdAt oldest-first.
  • date-utils.tsformatRelative rounds days (36h → "2 days ago"); future/past now symmetric.
  • validator.tsisEmail accepts multi-label domains and long TLDs; isUrl accepts URLs with explicit ports (protocol allowlist unchanged, still http/https only).

Assumptions

  • The tests are the authoritative spec; where a source TODO comment and the tests could differ, the tests were followed.
  • Behaviour beyond the failing tests was left unchanged except two consistency fixes made while implementing truncate/formatRelative (symmetric future dates; trailing-space trim on truncate).

Review notes (non-blocking, not required by tests)

A review pass confirmed no regressions and cleared formatRelative symmetry, isEmail ReDoS safety, and isUrl/task-manager correctness. It flagged 3 minor edge cases in the new truncate code, none exercised by the test suite and none merge-blocking:

  1. slice can split UTF-16 surrogate pairs (emoji) → lone surrogate.
  2. Leading-whitespace input can collapse the result to a bare "...".
  3. When maxLength <= 3 the ellipsis marker is dropped (hard cut).

Left as follow-ups to honour the "fix only what the tests require" constraint. Also noted: isEmail/isUrl are format checks, not input sanitisation.

🤖 Generated with QuantCode

…manager, date, and validator utils

- calculator.divide: throw on division by zero instead of returning Infinity
- string-utils.wordCount: split on whitespace runs (handles multiple spaces/tabs/newlines)
- string-utils.truncate: implement word-boundary truncation with ellipsis counted toward maxLength
- task-manager: implement remove/update return semantics and sortBy (priority, status, createdAt)
- date-utils.formatRelative: round days (and symmetric future/past) so 36h reads as 2 days
- validator: isEmail accepts multi-label domains/long TLDs; isUrl accepts explicit 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