diff options
Diffstat (limited to 'server/test/command/shuffle_ability_card_command_test.dart')
| -rw-r--r-- | server/test/command/shuffle_ability_card_command_test.dart | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/server/test/command/shuffle_ability_card_command_test.dart b/server/test/command/shuffle_ability_card_command_test.dart new file mode 100644 index 0000000..10eee0d --- /dev/null +++ b/server/test/command/shuffle_ability_card_command_test.dart @@ -0,0 +1,93 @@ +// ignore_for_file: avoid-late-keyword, avoid-non-null-assertion + +import 'package:test/test.dart'; +import 'package:x_haven_server/core/commands/add_monster_command.dart'; +import 'package:x_haven_server/core/commands/draw_ability_card_command.dart'; +import 'package:x_haven_server/core/commands/shuffle_ability_card_command.dart'; +import 'package:x_haven_server/core/commands/shuffle_amd_card_command.dart'; +import 'package:x_haven_server/core/commands/shuffle_drawn_ability_card_command.dart'; +import 'package:x_haven_server/core/game_methods.dart'; +import 'package:x_haven_server/core/state/game_state.dart'; +import 'package:x_haven_server/core/service_locator.dart'; + +import 'test_helpers.dart'; + +void main() { + setUpAll(() async { + await setUpGame(); + }); + + late Monster monster; + + setUp(() { + getIt<GameState>().clearList(); + AddMonsterCommand( + 'Ancient Artillery (FH)', + 1, + false, + gameState: getIt<GameState>(), + ).execute(); + monster = + getIt<GameState>().currentList.firstWhere((e) => e is Monster) + as Monster; + }); + + group('ShuffleAbilityCardCommand', () { + test('should shuffle ability deck (discard into draw pile)', () { + // Draw some cards into discard + DrawAbilityCardCommand(monster.id).execute(); + DrawAbilityCardCommand(monster.id).execute(); + final deck = GameMethods.getDeck(monster.type.deck)!; + expect(deck.discardPileIsNotEmpty, isTrue); + + ShuffleAbilityCardCommand(monster.id).execute(); + + expect(deck.discardPileContents, isEmpty); + checkSaveState(); + }); + + test('describe returns correct string', () { + expect( + ShuffleAbilityCardCommand(monster.id).describe(), + 'Extra ability deck shuffle', + ); + }); + }); + + group('ShuffleDrawnAbilityCardCommand', () { + test('should shuffle only undrawn part of ability deck', () { + final deck = GameMethods.getDeck(monster.type.deck)!; + final totalBefore = deck.drawPileSize + deck.discardPileSize; + + ShuffleDrawnAbilityCardCommand(monster.type.deck).execute(); + + final totalAfter = deck.drawPileSize + deck.discardPileSize; + expect(totalAfter, totalBefore); + }); + + test('describe returns correct string', () { + expect( + ShuffleDrawnAbilityCardCommand(monster.type.deck).describe(), + 'Drawn ability deck shuffle', + ); + }); + }); + + group('ShuffleAMDCardCommand', () { + test('describe returns correct string', () { + expect( + ShuffleAMDCardCommand('', gameState: getIt<GameState>()).describe(), + 'Extra AMD deck shuffle', + ); + }); + + test('should shuffle modifier deck draw pile', () { + final deck = getIt<GameState>().modifierDeck; + final sizeBefore = deck.drawPileSize; + + ShuffleAMDCardCommand('', gameState: getIt<GameState>()).execute(); + + expect(deck.drawPileSize, sizeBefore); + }); + }); +} |
