Description
📝 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
tofelt252
usingInto<BeastType, felt252>
BeastType
tou8
usingInto<BeastType, u8>
u8
toBeastType
usingInto<u8, BeastType>
-
Step 2: Verify correct bidirectional mapping:
- Each enum variant matches its corresponding numeric and felt252 value.
- Invalid
u8
inputs map toBeastType::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 inBeastType::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
- Please ensure you read and follow the contribution guidelines in the project's CONTRIBUTIONS GUIDELINES