Skip to content

test: add unit tests for src/utils/formatRemaining.ts (#1973) - #1998

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

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

Conversation

@s6pa1rta3n-lab

Copy link
Copy Markdown

Description

Adds comprehensive unit tests for src/utils/formatRemaining.ts in src/utils/__tests__/formatRemaining.test.ts with 100% statement, branch, function, and line coverage. Also provides the pure utility function with typed MaturityStatus and RemainingMaturity interfaces.

Closes #1973

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Stipulations & Acceptance Criteria Checklist

  • Pure utility function exports formatRemaining(maturityTimestamp, currentTimestamp)
  • Matured state verified when diffMs <= 0 (text: 'Matured', status: 'matured')
  • Critical threshold boundary covered (diffMs <= 1 day)
  • Warning threshold boundary covered (1 day < diffMs <= 7 days)
  • Healthy threshold boundary covered (diffMs > 7 days)
  • Formatting branch days > 0 covered (${days}d ${hours}h ${minutes}m and 0h handling)
  • Formatting branch days === 0 covered (hours omitted when zero, minutes only)
  • Deterministic timestamp testing verified via optional currentTimestamp parameter
  • Achieved 100% test coverage across statements, branches, functions, and lines

Checklist

  • My code follows the code style and standards of this project (strict TypeScript, components/functions/constants naming conventions).
  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated or added documentation where relevant (DEVELOPER_GUIDE.md, README.md, or inline files).
  • I have added unit/integration tests that prove my fix is effective or that my feature works.
  • Any new or modified logic has at least 95% test coverage (verified via pnpm run test:coverage or npm run test:coverage).
  • I have ran the project linter (pnpm lint or npm run lint) and fixed all error diagnostics.
  • I have verified that this change fits within the 96-hour campaign timeframe for contributor assignments.

Payout Routing

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

@vercel

vercel Bot commented Sep 28, 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.

Add unit tests for src/utils/formatRemaining.ts

1 participant