summaryrefslogtreecommitdiff
path: root/server/test/command/set_level_command_test.dart
diff options
context:
space:
mode:
Diffstat (limited to 'server/test/command/set_level_command_test.dart')
-rw-r--r--server/test/command/set_level_command_test.dart55
1 files changed, 55 insertions, 0 deletions
diff --git a/server/test/command/set_level_command_test.dart b/server/test/command/set_level_command_test.dart
new file mode 100644
index 0000000..3a2c1a8
--- /dev/null
+++ b/server/test/command/set_level_command_test.dart
@@ -0,0 +1,55 @@
+// ignore_for_file: no-magic-number
+
+import 'package:test/test.dart';
+import 'package:x_haven_server/core/commands/add_monster_command.dart';
+import 'package:x_haven_server/core/commands/set_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();
+ });
+
+ setUp(() {
+ getIt<GameState>().clearList();
+ });
+
+ group('SetLevelCommand', () {
+ test('should set global level when monsterId is null', () {
+ final command = SetLevelCommand(3, null);
+ command.execute();
+ expect(getIt<GameState>().level, 3);
+ checkSaveState();
+ });
+
+ test('should set a specific monster level when monsterId is provided', () {
+ AddMonsterCommand(
+ 'Ancient Artillery (FH)',
+ 1,
+ false,
+ gameState: getIt<GameState>(),
+ ).execute();
+ final monster =
+ getIt<GameState>().currentList.firstWhere((e) => e is Monster)
+ as Monster;
+
+ SetLevelCommand(4, monster.id).execute();
+
+ expect(monster.level, 4);
+ checkSaveState();
+ });
+
+ test('describe without monsterId returns "Set Level"', () {
+ final command = SetLevelCommand(2, null);
+ expect(command.describe(), 'Set Level');
+ });
+
+ test('describe with monsterId includes monster name', () {
+ final command = SetLevelCommand(2, 'Ancient Artillery (FH)');
+ expect(command.describe(), "Set Ancient Artillery (FH)'s level");
+ });
+ });
+}