summaryrefslogtreecommitdiff
path: root/server/test/command/set_difficulty_command_test.dart
blob: d63571be717fbf5726c4f1e8a79dad0419c82841 (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
// ignore_for_file: no-magic-number

import 'package:test/test.dart';
import 'package:x_haven_server/core/commands/set_difficulty_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('SetDifficultyCommand', () {
    test('should set difficulty to given value', () {
      final command = SetDifficultyCommand(2, gameState: getIt<GameState>());
      command.execute();
      expect(getIt<GameState>().difficulty, 2);
      checkSaveState();
    });

    test('should set difficulty to negative value', () {
      final command = SetDifficultyCommand(-1, gameState: getIt<GameState>());
      command.execute();
      expect(getIt<GameState>().difficulty, -1);
      checkSaveState();
    });

    test('describe should include difficulty level', () {
      final command = SetDifficultyCommand(3, gameState: getIt<GameState>());
      expect(command.describe(), 'Set difficulty level to 3');
    });
  });
}