summaryrefslogtreecommitdiff
path: root/server/test/command/set_ally_deck_in_og_gloom_command_test.dart
blob: 8e1659d300e6db0540d85be47e7e44a7f58eec80 (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
import 'package:test/test.dart';
import 'package:x_haven_server/core/commands/set_ally_deck_in_og_gloom_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();
  });

  group('SetAllyDeckInOgGloomCommand', () {
    test('should set allyDeckInOGGloom to false', () {
      SetAllyDeckInOgGloomCommand(
        false,
        gameState: getIt<GameState>(),
      ).execute();
      expect(getIt<GameState>().allyDeckInOGGloom, isFalse);
      checkSaveState();
    });

    test('should set allyDeckInOGGloom to true', () {
      SetAllyDeckInOgGloomCommand(
        false,
        gameState: getIt<GameState>(),
      ).execute();
      SetAllyDeckInOgGloomCommand(
        true,
        gameState: getIt<GameState>(),
      ).execute();
      expect(getIt<GameState>().allyDeckInOGGloom, isTrue);
      checkSaveState();
    });

    test('describe when false returns no-ally string', () {
      final command = SetAllyDeckInOgGloomCommand(
        false,
        gameState: getIt<GameState>(),
      );
      expect(
        command.describe(),
        'No ally deck in 1st edition Gloomhaven campaigns',
      );
    });

    test('describe when true returns use-ally string', () {
      final command = SetAllyDeckInOgGloomCommand(
        true,
        gameState: getIt<GameState>(),
      );
      expect(
        command.describe(),
        'Use Ally Deck in 1st edition Gloomhaven Campaigns',
      );
    });

    test('undo does not throw', () {
      final gs = getIt<GameState>();
      gs.action(
        SetAllyDeckInOgGloomCommand(true, gameState: getIt<GameState>()),
      );
      expect(() => gs.undo(), returnsNormally);
    });
  });
}