summaryrefslogtreecommitdiff
path: root/server/test/command/set_loot_owner_command_test.dart
blob: 00d95a95c3f9b7f4164c70a4d7262da975bd874f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import 'package:test/test.dart';
import 'package:x_haven_server/core/commands/add_character_command.dart';
import 'package:x_haven_server/core/commands/draw_loot_card_command.dart';
import 'package:x_haven_server/core/commands/set_campaign_command.dart';
import 'package:x_haven_server/core/commands/set_loot_owner_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(() {
    getIt<GameState>().clearList();
    AddCharacterCommand('Blinkblade', 'Frosthaven', 'blinky', 1).execute();
    SetCampaignCommand('Frosthaven').execute();
    SetScenarioCommand(
      'custom',
      false,
      gameState: getIt<GameState>(),
    ).execute();
    DrawLootCardCommand(gameState: getIt<GameState>()).execute();
  });

  group('SetLootOwnerCommand', () {
    test('should set owner on the loot card', () {
      final lootDeck = getIt<GameState>().lootDeck;
      final card = lootDeck.discardPileTop;
      expect(card.owner, isEmpty);

      SetLootOwnerCommand('Blinkblade', card).execute();

      expect(card.owner, 'Blinkblade');
      checkSaveState();
    });

    test('describe returns correct string', () {
      final lootDeck = getIt<GameState>().lootDeck;
      final card = lootDeck.discardPileTop;
      final command = SetLootOwnerCommand('Blinkblade', card);
      expect(command.describe(), 'Set loot card owner');
    });
  });
}