Skip to content

test: add unit tests for frontend bignumber and utilities helpers - #13

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1784700452-frontend-helper-tests
Open

test: add unit tests for frontend bignumber and utilities helpers#13
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1784700452-frontend-helper-tests

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Jul 22, 2026

Copy link
Copy Markdown

Summary

Coverage analysis: the repo had effectively no meaningful unit tests. Blockchain has only the default Hardhat test/Lock.ts (which references a non-existent Lock contract), backend has none, and frontend has only the default CRA App.test.tsx. Measuring the frontend src/helpers / src/constants modules confirmed 0% coverage across the board.

The two largest, least-covered pure-logic modules are frontend/src/helpers/bignumber.ts (204 lines) and frontend/src/helpers/utilities.ts (220 lines) — ideal for unit testing since they don't require network/web3 mocks. This PR adds Jest tests (run via the existing react-app-rewired test) for them.

Coverage for the two files after this PR:

File          | % Stmts | % Funcs | % Lines
bignumber.ts  |     100 |     100 |     100   (was 0)
utilities.ts  |   37.31 |      50 |   37.31   (was 0)

utilities.ts is partially covered because most of it is async network/API calls (apiGet*, formatTestTransaction); the tests cover the pure functions: isObject, sanitizeHex, convertStringToHex, convertNumberToString, getChainData (known chain, unknown-chain fallback, and Infura %API_KEY% substitution branch), and hashPersonalMessage (deterministic EIP-191 hash).

bignumber.ts tests cover all exported predicates, conversions, comparisons, arithmetic (incl. big-integer precision), raw-number conversion round-trips, and the formatting helpers.

Notes:

  • recoverPublicKey was intentionally not tested — its secp256k1 path rejects jsdom's browserified Buffer polyfill (Expected private key to be an Uint8Array), so it isn't reliably unit-testable in the CRA jsdom environment.
  • 46 tests total, all passing; tsc --noEmit is clean.

Test plan

cd frontend
npm i
CI=true npx react-app-rewired test src/helpers/bignumber.test.ts src/helpers/utilities.test.ts --watchAll=false

Link to Devin session: https://app.devin.ai/sessions/0fee9282ef36488383c821a634211ba4
Requested by: @walnutwaldo


Devin Review

Status Commit
⚪ Not started

Run Devin Review

Open in Devin Review (Staging)

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@walnutwaldo walnutwaldo self-assigned this Jul 22, 2026
@devin-ai-integration

Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

@github-actions

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit 391419e):

https://decentralized-dall-e--pr13-devin-1784700452-fro-cu73ngb3.web.app

(expires Wed, 29 Jul 2026 06:10:51 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 9f3ca659ce42113c1a9d85a3ba19a54f05478557

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