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
|
// ignore_for_file: no-magic-number, avoid-late-keyword
import 'package:test/test.dart';
import 'package:x_haven_server/core/commands/add_character_command.dart';
import 'package:x_haven_server/core/commands/set_init_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();
});
late Character character;
setUp(() {
getIt<GameState>().clearList();
AddCharacterCommand('Banner Spear', 'Frosthaven', 'BS', 1).execute();
character =
getIt<GameState>().currentList.firstWhere((e) => e is Character)
as Character;
});
group('SetInitCommand', () {
test('should set initiative for a character', () {
final command = SetInitCommand(
character.id,
15,
gameState: getIt<GameState>(),
);
command.execute();
expect(character.characterState.initiative, 15);
checkSaveState();
});
test('should update initiative to a new value', () {
SetInitCommand(character.id, 10, gameState: getIt<GameState>()).execute();
SetInitCommand(character.id, 25, gameState: getIt<GameState>()).execute();
expect(character.characterState.initiative, 25);
});
test('describe should include character id', () {
final command = SetInitCommand(
'Blinkblade',
15,
gameState: getIt<GameState>(),
);
expect(command.describe(), 'Set initiative of Blinkblade');
});
});
}
|