fix(test): use get_node_or_null in detach position test per project convention
This commit is contained in:
@@ -180,6 +180,67 @@ func test_detach_item_preserves_global_position() -> void:
|
|||||||
add_child_autofree(item)
|
add_child_autofree(item)
|
||||||
_char.global_position = Vector2(200.0, 300.0)
|
_char.global_position = Vector2(200.0, 300.0)
|
||||||
_char.attach_item("left", item)
|
_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")
|
_char.detach_item("left")
|
||||||
assert_eq(item.global_position, expected_global)
|
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), "")
|
||||||
|
|||||||
Reference in New Issue
Block a user