summaryrefslogtreecommitdiff
path: root/server/test/command/remove_special_loot_card_command_test.dart
blob: 4c1ba1a72d29bd7a8bae7c94a63080b826ee1f2d (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// ignore_for_file: no-magic-number

import 'package:test/test.dart';
import 'package:x_haven_server/core/commands/add_special_loot_card_command.dart';
import 'package:x_haven_server/core/commands/remove__special_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('RemoveSpecialLootCardCommand', () {
    test('should remove special card 1418 from draw pile', () {
      AddSpecialLootCardCommand(1418, gameState: getIt<GameState>()).execute();
      final lootDeck = getIt<GameState>().lootDeck;
      expect(lootDeck.hasCard1418, isTrue);

      RemoveSpecialLootCardCommand(
        1418,
        gameState: getIt<GameState>(),
      ).execute();

      expect(lootDeck.hasCard1418, isFalse);
      checkSaveState();
    });

    test('should remove special card 1419 from draw pile', () {
      AddSpecialLootCardCommand(1419, gameState: getIt<GameState>()).execute();
      final lootDeck = getIt<GameState>().lootDeck;
      expect(lootDeck.hasCard1419, isTrue);

      RemoveSpecialLootCardCommand(
        1419,
        gameState: getIt<GameState>(),
      ).execute();

      expect(lootDeck.hasCard1419, isFalse);
      checkSaveState();
    });

    test('should do nothing for unknown card nr', () {
      final lootDeck = getIt<GameState>().lootDeck;
      final countBefore = lootDeck.drawPileSize;

      RemoveSpecialLootCardCommand(
        9999,
        gameState: getIt<GameState>(),
      ).execute();

      expect(lootDeck.drawPileSize, countBefore);
    });

    test('describe includes the card number', () {
      final command = RemoveSpecialLootCardCommand(
        1418,
        gameState: getIt<GameState>(),
      );
      expect(command.describe(), 'Remove Special loot card 1418');
    });
  });
}