diff options
Diffstat (limited to 'server/test/command/enhance_loot_card_command_test.dart')
| -rw-r--r-- | server/test/command/enhance_loot_card_command_test.dart | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/server/test/command/enhance_loot_card_command_test.dart b/server/test/command/enhance_loot_card_command_test.dart new file mode 100644 index 0000000..73ebc3b --- /dev/null +++ b/server/test/command/enhance_loot_card_command_test.dart @@ -0,0 +1,82 @@ +// ignore_for_file: no-magic-number + +import 'package:test/test.dart'; +import 'package:x_haven_server/core/commands/enhance_loot_card_command.dart'; +import 'package:x_haven_server/core/commands/set_campaign_command.dart'; +import 'package:x_haven_server/core/commands/set_scenario_command.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(); + }); + + setUp(() { + SetCampaignCommand('Frosthaven').execute(); + SetScenarioCommand( + '#0 Howling in the Snow', + false, + gameState: getIt<GameState>(), + ).execute(); + }); + + group('EnhanceLootCardCommand', () { + test('should add an enhancement to a loot card', () { + final lootDeck = getIt<GameState>().lootDeck; + // Get any existing card id from the draw pile + if (lootDeck.drawPileIsNotEmpty) { + final cardId = lootDeck.drawPileContents.toList().first.id; + + EnhanceLootCardCommand( + cardId, + 2, + 'coin', + gameState: getIt<GameState>(), + ).execute(); + + // After enhancement the deck is rebuilt; verify it doesn't crash + expect(lootDeck.drawPileIsNotEmpty, isTrue); + checkSaveState(); + } + }); + + test('describe returns "Add Loot Enhancement" when value is positive', () { + expect( + EnhanceLootCardCommand( + 1, + 1, + 'coin', + gameState: getIt<GameState>(), + ).describe(), + 'Add Loot Enhancement', + ); + }); + + test( + 'describe returns "Remove Loot Enhancement" when value is zero or negative', + () { + expect( + EnhanceLootCardCommand( + 1, + 0, + 'coin', + gameState: getIt<GameState>(), + ).describe(), + 'Remove Loot Enhancement', + ); + expect( + EnhanceLootCardCommand( + 1, + -1, + 'coin', + gameState: getIt<GameState>(), + ).describe(), + 'Remove Loot Enhancement', + ); + }, + ); + }); +} |
