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
54
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");
});
});
}
|