Skip to content

Add unit tests for hasValuableMoves and integration with game-over #401

@SorraTheOrc

Description

@SorraTheOrc

Summary

Add comprehensive tests for the new hasValuableMoves() function and verify its integration with the game-over detection flow.

Tests to Add

Unit tests for hasValuableMoves (in BeleagueredCastleRules.test.ts)

  1. Board with only non-valuable moves detects as game-over: Construct a state where the only legal moves are tableau-to-tableau shuffles that don't expose new cards. Verify hasValuableMoves() returns false.

  2. Board with at least one valuable move is NOT game-over: Construct a state where at least one move exposes a new card or creates a new foundation opportunity. Verify hasValuableMoves() returns true.

  3. Foundation move is always valuable: A state where the only legal move is a tableau-to-foundation move. Should return true.

  4. Empty tableau columns: Edge case where some columns are empty but moves between remaining columns don't help.

  5. Single-card columns: State with single-card columns where moves expose the empty column (which is a new move target).

  6. No legal moves at all: Verify returns false (consistent with hasNoMoves).

  7. Fresh deal has valuable moves: A normal deal should always have at least one valuable move.

  8. State is not mutated: Verify the state is identical before and after calling hasValuableMoves.

Integration tests (in Integration.test.ts)

  1. Full game detects stuck state: Play a game that reaches a stuck position and verify the game ends appropriately.

Acceptance Criteria

  • All listed test cases are implemented and pass
  • All existing tests continue to pass
  • Tests cover the key edge cases from the parent work item's AC

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions