Skip to content

Add Tests for NFT Repository (Reference Handling) #152

@Villarley

Description

@Villarley

Description

The NFTRepository (src/modules/nft/repositories/nft.repository.ts) is responsible for persisting and retrieving NFT entities.
To ensure correctness and reliability, we need to add comprehensive tests with special focus on how the repository handles references to NFTs (IDs, user ownership, relations).

This will provide confidence in NFT persistence logic and act as documentation for how NFTs are referenced throughout the system.

What is expected

  • A new test suite for NFTRepository covering reference-related operations.
  • Verification that NFTs can be:
    • Created and correctly referenced by ID.
    • Queried by user ID or project association.
    • Deleted and no longer retrievable by reference.
  • Ensure repository behavior aligns with existing domain contracts (INFTRepository).

What should be modified

  1. Add a new test file:
    src/modules/nft/__tests__/repositories/nft.repository.test.ts
  2. Write unit tests for:
    • createNFT() – creates an NFT and returns its reference.
    • getNFTById() – retrieves an NFT using its ID.
    • getNFTByUserId() – retrieves NFTs owned by a specific user.
    • deleteNFT() – removes an NFT and ensures the reference is gone.
  3. Mock Prisma client or use the SQLite test DB (.env.test).
  4. Follow test patterns from existing repositories, e.g.:
    • message-prisma.repository.test.ts
    • volunteer-prisma.repository.test.ts
  5. Run full test suite and ensure all tests pass.

Acceptance criteria

  • New test suite exists under src/modules/nft/__tests__/repositories/.
  • All reference-related methods in NFTRepository are tested.
  • CRUD operations behave as expected in tests.
  • Test coverage for nft.repository.ts is >= 80%.
  • Tests run successfully with npm test.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions