Skip to content

Add unit tests for validation utility functions #477

Description

@DeFiVC

What

Add unit tests for the validation functions and Zod schemas in src/lib/utils/validation.ts.

Why

Validation functions are critical for data integrity across forms (profile updates, quiz submissions, reward claims). Without tests, regressions in validation logic could allow invalid data through or reject valid input.

Scope

  • Create src/lib/utils/__tests__/validation.test.ts
  • Test all exported validators and Zod schemas
  • No source code changes

Acceptance Criteria

  • Tests for isValidStellarAddress (valid, wrong length, wrong prefix, invalid checksum)
  • Tests for isValidEd25519PublicKey (valid, invalid)
  • Tests for isValidContractId (valid, invalid)
  • Tests for required, minLength, maxLength, displayName, composeValidators
  • Tests for Zod schemas: profileUpdateSchema, courseCreateSchema, quizSubmitSchema, rewardClaimSchema
  • Tests for both valid and invalid inputs
  • npm test passes

Technical Context

File: src/lib/utils/validation.ts
Exports:

  • Functions: isValidStellarAddress, isValidEd25519PublicKey, isValidContractId, required, minLength, maxLength, stellarAddress, displayName, composeValidators
  • Schemas: profileUpdateSchema, courseCreateSchema, quizSubmitSchema, rewardClaimSchema

Labels: tests

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave programmediumFunctionality impaired but workaround exists, edge case, partial featuretestsTest additions or improvements

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions