Skip to content

📝 [FEAT] Add Unit Tests for BeastType Enum and Conversions #93

@jimenezz22

Description

@jimenezz22

📝 Issue Title: Add Unit Tests for BeastType Enum and Conversions

🔍 Scope

The BeastType enum defines different elemental and magical types for beasts, each with custom conversions to felt252 and u8. While the logic is implemented, there are currently no unit tests validating the behavior of these conversions.

This issue involves writing a complete set of unit tests to ensure BeastType conversion logic is correct, handles edge cases, and behaves safely in the game logic.

🔄 How to Implement the Issue

  • Step 1: Write tests for the following:

    • BeastType to felt252 using Into<BeastType, felt252>
    • BeastType to u8 using Into<BeastType, u8>
    • u8 to BeastType using Into<u8, BeastType>
  • Step 2: Verify correct bidirectional mapping:

    • Each enum variant matches its corresponding numeric and felt252 value.
    • Invalid u8 inputs map to BeastType::Undefined.
  • Step 3: Add edge case testing (e.g., max u8 value 255).

✅ Acceptance Criteria

  • Unit tests exist for each Into implementation.
  • Tests confirm all valid mappings are correct.
  • Invalid u8 values result in BeastType::Undefined.
  • Tests follow Cairo and Dojo testing conventions.

📸 Additional Context

The BeastType enum plays a key role in game classification, elemental interactions, and behavior logic. Ensuring safe and accurate conversions will prevent state inconsistencies or unexpected logic behavior during battles or UI rendering.

Enum source:
https://github.com/AkatsukiLabs/DojoByExample/blob/main/backend/dojo_examples/combat_game/src/types/beast.cairo

Contribution Guidelines

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions