Skip to content

test(utils): add tests for unrecognized sortBy and malformed numeric fields (#1978) - #2003

Draft
s6pa1rta3n-lab wants to merge 1 commit into
Commitlabs-Org:masterfrom
s6pa1rta3n-lab:fix-issue-1978
Draft

s6pa1rta3n-lab wants to merge 1 commit into
Commitlabs-Org:masterfrom
s6pa1rta3n-lab:fix-issue-1978

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Summary

Resolves #1978 by adding test coverage for default case handling of unrecognized sortBy values and handling of malformed numeric and date fields in sortCommitments.

Changes

  • Testing: Added unit test asserting that an unrecognized sortBy option returns the input commitments order and identity unchanged.
  • Testing: Added unit tests covering malformed numeric and amount fields (amount, daysRemaining, complianceScore, changePercent) across numeric sort options (ValueHighLow, ValueLowHigh, MaturitySoonest, MaturityLatest, ComplianceHighLow, ComplianceLowHigh, YieldHighLow, YieldLowHigh).
  • Testing: Added unit tests covering invalid date strings in Newest and Oldest sort options.
  • Testing: Added unit test asserting input array immutability during sorting.
  • Testing: Mirrored test suite in both src/utils/tests/sortCommitments.test.ts and src/utils/tests/sortCommitments.test.ts to satisfy repository structure and explicit path reference in sortCommitments has no test for its default case or malformed numeric fields #1978.
  • Implementation: Added JSDoc docstrings for SortOption and sortCommitments.
  • Implementation: Hardened parseAmount, parseNumeric, and added parseDate in src/utils/sortCommitments.ts with defensive fallback guards against NaN, non-string, null, and undefined values.

Verification

  • Automated tests: 38/38 tests passing across both test locations.
  • Code coverage: 100% statement, 100% branch, 100% function, 100% line coverage on sortCommitments.ts.
  • ESLint and Prettier: 0 errors, 100% compliant.

Payout Routing

  • EVM (Base/Arbitrum/Polygon/ETH): 0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89
  • Stellar: GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC

@vercel

vercel Bot commented Sep 29, 2026

Copy link
Copy Markdown

@s6pa1rta3n-lab is attempting to deploy a commit to the 1nonly's projects Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

sortCommitments has no test for its default case or malformed numeric fields

1 participant