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