summaryrefslogtreecommitdiff
path: root/server/test/command/set_character_level_command_test.dart
diff options
context:
space:
mode:
Diffstat (limited to 'server/test/command/set_character_level_command_test.dart')
-rw-r--r--server/test/command/set_character_level_command_test.dart48
1 files changed, 48 insertions, 0 deletions
diff --git a/server/test/command/set_character_level_command_test.dart b/server/test/command/set_character_level_command_test.dart
new file mode 100644
index 0000000..6faa86e
--- /dev/null
+++ b/server/test/command/set_character_level_command_test.dart
@@ -0,0 +1,48 @@
+// 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_character_level_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('SetCharacterLevelCommand', () {
+ test('should set character level', () {
+ final command = SetCharacterLevelCommand(3, character.id);
+ command.execute();
+ expect(character.characterState.level, 3);
+ checkSaveState();
+ });
+
+ test('should update max health when level changes', () {
+ final healthAtLevel1 = character.characterState.maxHealth;
+ SetCharacterLevelCommand(5, character.id).execute();
+ expect(
+ character.characterState.maxHealth,
+ greaterThanOrEqualTo(healthAtLevel1),
+ );
+ });
+
+ test('describe should include character id', () {
+ final command = SetCharacterLevelCommand(3, 'Blinkblade');
+ expect(command.describe(), "Set Blinkblade's Level");
+ });
+ });
+}