Files
Cozypaw-Hospital/test/unit/test_character_v2.gd
T

115 lines
3.1 KiB
GDScript

## Tests for Character System v2 — animation state, outfit layers, hand slots.
extends GutTest
var _char: Character
func before_each() -> void:
_char = preload("res://scenes/characters/Character.tscn").instantiate() as Character
add_child_autofree(_char)
var cd: CharacterData = CharacterData.new()
_char.data = cd
func test_animated_sprite_node_exists() -> void:
assert_not_null(_char.get_node_or_null("AnimatedSprite2D"))
func test_outfit_layer_1_node_exists() -> void:
assert_not_null(_char.get_node_or_null("OutfitLayer1"))
func test_outfit_layer_2_node_exists() -> void:
assert_not_null(_char.get_node_or_null("OutfitLayer2"))
func test_outfit_layer_3_node_exists() -> void:
assert_not_null(_char.get_node_or_null("OutfitLayer3"))
func test_hand_left_node_exists() -> void:
assert_not_null(_char.get_node_or_null("HandLeft"))
func test_hand_right_node_exists() -> void:
assert_not_null(_char.get_node_or_null("HandRight"))
func test_snap_receiver_node_exists() -> void:
assert_not_null(_char.get_node_or_null("SnapReceiver"))
func test_character_data_outfit_has_three_empty_slots() -> void:
assert_eq(_char.data.outfit.size(), 3)
assert_eq(_char.data.outfit[0], "")
assert_eq(_char.data.outfit[1], "")
assert_eq(_char.data.outfit[2], "")
func test_default_animation_state_is_idle() -> void:
assert_eq(_char.get_animation_state(), "idle")
func test_set_animation_state_sitting() -> void:
_char.set_animation_state("sitting")
assert_eq(_char.get_animation_state(), "sitting")
func test_set_animation_state_lying() -> void:
_char.set_animation_state("lying")
assert_eq(_char.get_animation_state(), "lying")
func test_set_animation_state_held() -> void:
_char.set_animation_state("held")
assert_eq(_char.get_animation_state(), "held")
func test_set_animation_state_happy() -> void:
_char.set_animation_state("happy")
assert_eq(_char.get_animation_state(), "happy")
func test_set_animation_state_sleeping() -> void:
_char.set_animation_state("sleeping")
assert_eq(_char.get_animation_state(), "sleeping")
func test_get_outfit_returns_empty_for_all_layers_initially() -> void:
assert_eq(_char.get_outfit(1), "")
assert_eq(_char.get_outfit(2), "")
assert_eq(_char.get_outfit(3), "")
func test_set_outfit_stores_item_id() -> void:
_char.set_outfit(1, "white_coat", null)
assert_eq(_char.get_outfit(1), "white_coat")
func test_set_outfit_does_not_affect_other_layers() -> void:
_char.set_outfit(1, "white_coat", null)
assert_eq(_char.get_outfit(2), "")
assert_eq(_char.get_outfit(3), "")
func test_clear_outfit_returns_item_id() -> void:
_char.set_outfit(2, "cast_arm", null)
var returned: String = _char.clear_outfit(2)
assert_eq(returned, "cast_arm")
func test_clear_outfit_empties_layer() -> void:
_char.set_outfit(2, "cast_arm", null)
_char.clear_outfit(2)
assert_eq(_char.get_outfit(2), "")
func test_set_outfit_invalid_layer_zero_is_noop() -> void:
_char.set_outfit(0, "white_coat", null)
assert_eq(_char.get_outfit(1), "")
func test_set_outfit_invalid_layer_four_is_noop() -> void:
_char.set_outfit(4, "white_coat", null)
assert_eq(_char.get_outfit(3), "")