summaryrefslogtreecommitdiff
path: root/server/test/command/set_auto_level_adjust_command_test.dart
blob: d9cd253e264c2cd8122546ff3f0331c6f4dad0a4 (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
import 'package:test/test.dart';
import 'package:x_haven_server/core/commands/set_auto_level_adjust_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('SetAutoLevelAdjustCommand', () {
    test('should turn auto level adjust on', () {
      final command = SetAutoLevelAdjustCommand(
        true,
        gameState: getIt<GameState>(),
      );
      command.execute();
      expect(getIt<GameState>().autoScenarioLevel, isTrue);
      checkSaveState();
    });

    test('should turn auto level adjust off', () {
      SetAutoLevelAdjustCommand(true, gameState: getIt<GameState>()).execute();
      final command = SetAutoLevelAdjustCommand(
        false,
        gameState: getIt<GameState>(),
      );
      command.execute();
      expect(getIt<GameState>().autoScenarioLevel, isFalse);
      checkSaveState();
    });

    test('describe should say "on" when enabled', () {
      final command = SetAutoLevelAdjustCommand(
        true,
        gameState: getIt<GameState>(),
      );
      expect(command.describe(), 'Turn automatic level update on');
    });

    test('describe should say "off" when disabled', () {
      final command = SetAutoLevelAdjustCommand(
        false,
        gameState: getIt<GameState>(),
      );
      expect(command.describe(), 'Turn automatic level update off');
    });
  });
}