Skip to content

fix: make all failing tests pass - #329

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2177-1788940441
Open

fix: make all failing tests pass#329
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier1-2177-1788940441

Conversation

@stooit

@stooit stooit commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all 16 failing tests across the 5 utility modules and implements the missing functionality. Test suite went from 44 pass / 16 fail → 60 pass / 0 fail (bun test). tsc --noEmit is clean.

Changes by file

  • src/calculator.tsdivide now throws "Division by zero" when the divisor is 0 (was returning Infinity).
  • src/string-utils.ts — implemented truncate (word-boundary truncation with "..." counting toward maxLength, unchanged when within limit); fixed wordCount to collapse consecutive whitespace via trim().split(/\s+/).
  • src/task-manager.ts — implemented remove (Map.delete boolean semantics), update (per-field !== undefined guards), and sortBy (priority high→medium→low and createdAt oldest-first, sorting a copy).
  • src/date-utils.ts — fixed off-by-one in formatRelative day bucket (Math.floorMath.round); e.g. 36h now reads "2 days ago".
  • src/validator.tsisEmail TLD length {2,4}{2,} (accepts long TLDs); isUrl dropped the erroneous port === "" check that rejected all URLs with a port, protocol allow-list (http/https only) retained.

Verification

  • bun test → 60 pass / 0 fail
  • bunx tsc --noEmit → clean
  • No test files modified; no dependencies added; package.json unchanged.

Assumptions

  • Fixed only what the tests require, per task constraints.
  • sortBy("status") ordering (in_progress → pending → completed) is an untested judgement call to satisfy the union type; nothing depends on it.

Non-blocking review notes (out of test scope, left as-is)

A review flagged three defensive-hardening items not covered by tests and not reachable from current callers: truncate with negative maxLength could exceed the limit; sortBy has no default arm; update can't clear an optional description. Left to honour the "fix only what the tests require" constraint.

Implements truncate and TaskManager remove/update/sortBy; fixes
wordCount whitespace handling, divide-by-zero guard, day rounding
in formatRelative, email TLD length, and URL port rejection.

All 60 tests pass (was 44 pass / 16 fail). No test files or
dependencies modified.
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