fix: make all failing tests pass - #329
Open
stooit wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 --noEmitis clean.Changes by file
src/calculator.ts—dividenow throws"Division by zero"when the divisor is0(was returningInfinity).src/string-utils.ts— implementedtruncate(word-boundary truncation with"..."counting towardmaxLength, unchanged when within limit); fixedwordCountto collapse consecutive whitespace viatrim().split(/\s+/).src/task-manager.ts— implementedremove(Map.delete boolean semantics),update(per-field!== undefinedguards), andsortBy(priority high→medium→low and createdAt oldest-first, sorting a copy).src/date-utils.ts— fixed off-by-one informatRelativeday bucket (Math.floor→Math.round); e.g. 36h now reads "2 days ago".src/validator.ts—isEmailTLD length{2,4}→{2,}(accepts long TLDs);isUrldropped the erroneousport === ""check that rejected all URLs with a port, protocol allow-list (http/https only) retained.Verification
bun test→ 60 pass / 0 failbunx tsc --noEmit→ cleanpackage.jsonunchanged.Assumptions
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:
truncatewith negativemaxLengthcould exceed the limit;sortByhas nodefaultarm;updatecan't clear an optionaldescription. Left to honour the "fix only what the tests require" constraint.