proofchain/packages/web/test/amount.test.ts
caelum0x 0aff927c78 feat: ProofChain production build across 5 packages
- contracts: ProvenanceRegistry, AttestationRegistry, SettlementEscrow, MockUSDC
  (Foundry, OZ AccessControl/SafeERC20/ReentrancyGuard/Pausable), 55 tests
- shared: typed ABI/type/address layer (viem, Base Sepolia)
- agent: Fastify + Claude tool-calling verification service, deterministic
  scoring reconciliation, on-chain attest/settle, 73 tests
- web: Next.js 15 dApp (wagmi/viem/RainbowKit) — supplier/buyer/verifier/deal, 80 tests
- infra: Supabase schema + client, IPFS (Pinata + local fallback), 45 tests
- integrated, security + TS reviewed, 18 findings fixed; 314 tests green

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-31 16:46:57 +03:00

27 lines
975 B
TypeScript

import { describe, expect, it } from "vitest";
import { parseTokenInput } from "@/lib/amount";
describe("parseTokenInput", () => {
it("parses whole numbers", () => {
expect(parseTokenInput("1000", 6)).toEqual({ value: 1_000_000_000n, error: null });
});
it("parses fractional values", () => {
expect(parseTokenInput("1.5", 6)).toEqual({ value: 1_500_000n, error: null });
});
it("rejects empty", () => {
expect(parseTokenInput("", 6).error).toMatch(/required/i);
});
it("rejects non-numeric", () => {
expect(parseTokenInput("abc", 6).error).toMatch(/positive number/i);
});
it("rejects zero", () => {
expect(parseTokenInput("0", 6).error).toMatch(/greater than zero/i);
});
it("rejects too many decimals", () => {
expect(parseTokenInput("1.1234567", 6).error).toMatch(/decimal places/i);
});
it("accepts max-precision value", () => {
expect(parseTokenInput("0.000001", 6)).toEqual({ value: 1n, error: null });
});
});