From 09033b9401b3afa2ce5b42cdab0d30855cc5bfcb Mon Sep 17 00:00:00 2001 From: Steven Wroblewski Date: Sat, 9 May 2026 00:09:53 +0200 Subject: [PATCH] fix(test): use get_node_or_null in detach position test per project convention --- test/unit/test_character_v2.gd | 63 +++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/test/unit/test_character_v2.gd b/test/unit/test_character_v2.gd index 4825a99..10aa1cc 100644 --- a/test/unit/test_character_v2.gd +++ b/test/unit/test_character_v2.gd @@ -180,6 +180,67 @@ func test_detach_item_preserves_global_position() -> void: add_child_autofree(item) _char.global_position = Vector2(200.0, 300.0) _char.attach_item("left", item) - var expected_global: Vector2 = _char.get_node("HandLeft").global_position + var expected_global: Vector2 = (_char.get_node_or_null("HandLeft") as Node2D).global_position _char.detach_item("left") assert_eq(item.global_position, expected_global) + + +func test_apply_outfit_item_hides_item() -> void: + var item: Node2D = Node2D.new() + add_child_autofree(item) + _char.apply_outfit_item(1, "white_coat", null, item) + assert_false(item.visible) + + +func test_apply_outfit_item_sets_outfit_data() -> void: + var item: Node2D = Node2D.new() + add_child_autofree(item) + _char.apply_outfit_item(1, "white_coat", null, item) + assert_eq(_char.get_outfit(1), "white_coat") + + +func test_remove_outfit_restores_item_visibility() -> void: + var item: Node2D = Node2D.new() + add_child_autofree(item) + _char.apply_outfit_item(2, "cast_arm", null, item) + _char.remove_outfit(2) + assert_true(item.visible) + + +func test_remove_outfit_clears_outfit_data() -> void: + var item: Node2D = Node2D.new() + add_child_autofree(item) + _char.apply_outfit_item(2, "cast_arm", null, item) + _char.remove_outfit(2) + assert_eq(_char.get_outfit(2), "") + + +func test_apply_outfit_item_replaces_existing() -> void: + var item1: Node2D = Node2D.new() + var item2: Node2D = Node2D.new() + add_child_autofree(item1) + add_child_autofree(item2) + _char.apply_outfit_item(1, "white_coat", null, item1) + _char.apply_outfit_item(1, "doctor_coat", null, item2) + assert_true(item1.visible) + assert_false(item2.visible) + assert_eq(_char.get_outfit(1), "doctor_coat") + + +func test_tap_removes_topmost_active_outfit_layer() -> void: + var item1: Node2D = Node2D.new() + var item3: Node2D = Node2D.new() + add_child_autofree(item1) + add_child_autofree(item3) + _char.apply_outfit_item(1, "white_coat", null, item1) + _char.apply_outfit_item(3, "stethoscope", null, item3) + _char._handle_outfit_tap() + assert_eq(_char.get_outfit(3), "") + assert_eq(_char.get_outfit(1), "white_coat") + + +func test_tap_noop_when_no_outfit_active() -> void: + _char._handle_outfit_tap() + assert_eq(_char.get_outfit(1), "") + assert_eq(_char.get_outfit(2), "") + assert_eq(_char.get_outfit(3), "")