summaryrefslogtreecommitdiff
path: root/server/test/command/set_init_command_test.dart
diff options
context:
space:
mode:
Diffstat (limited to 'server/test/command/set_init_command_test.dart')
-rw-r--r--server/test/command/set_init_command_test.dart53
1 files changed, 53 insertions, 0 deletions
diff --git a/server/test/command/set_init_command_test.dart b/server/test/command/set_init_command_test.dart
new file mode 100644
index 0000000..1637566
--- /dev/null
+++ b/server/test/command/set_init_command_test.dart
@@ -0,0 +1,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');
+ });
+ });
+}