## Tests verifying SnapPoints exist in all 2.OG and Garten room scenes.
extends GutTest


func _count_snaps(room: Node2D) -> int:
	var count: int = 0
	for child: Node in room.get_children():
		if child is SnapPoint:
			count += 1
	return count


func _count_snaps_with_pose(room: Node2D, pose: String) -> int:
	var count: int = 0
	for child: Node in room.get_children():
		var snap: SnapPoint = child as SnapPoint
		if snap != null and snap.pose == pose:
			count += 1
	return count


func _count_snaps_baby_only(room: Node2D) -> int:
	var count: int = 0
	for child: Node in room.get_children():
		var snap: SnapPoint = child as SnapPoint
		if snap != null and snap.baby_only:
			count += 1
	return count


func test_ultrasound_has_one_snap_point() -> void:
	var room: Node2D = preload("res://scenes/rooms/floor2/Ultrasound.tscn").instantiate() as Node2D
	add_child_autofree(room)
	assert_eq(_count_snaps(room), 1)


func test_ultrasound_snap_is_lying() -> void:
	var room: Node2D = preload("res://scenes/rooms/floor2/Ultrasound.tscn").instantiate() as Node2D
	add_child_autofree(room)
	assert_eq(_count_snaps_with_pose(room, "lying"), 1)


func test_delivery_room_has_one_snap_point() -> void:
	var room: Node2D = preload("res://scenes/rooms/floor2/DeliveryRoom.tscn").instantiate() as Node2D
	add_child_autofree(room)
	assert_eq(_count_snaps(room), 1)


func test_delivery_room_snap_is_lying() -> void:
	var room: Node2D = preload("res://scenes/rooms/floor2/DeliveryRoom.tscn").instantiate() as Node2D
	add_child_autofree(room)
	assert_eq(_count_snaps_with_pose(room, "lying"), 1)


func test_nursery_has_three_snap_points() -> void:
	var room: Node2D = preload("res://scenes/rooms/floor2/Nursery.tscn").instantiate() as Node2D
	add_child_autofree(room)
	assert_eq(_count_snaps(room), 3)


func test_nursery_all_snaps_are_baby_only() -> void:
	var room: Node2D = preload("res://scenes/rooms/floor2/Nursery.tscn").instantiate() as Node2D
	add_child_autofree(room)
	assert_eq(_count_snaps_baby_only(room), 3)


func test_nursery_all_snaps_are_lying() -> void:
	var room: Node2D = preload("res://scenes/rooms/floor2/Nursery.tscn").instantiate() as Node2D
	add_child_autofree(room)
	assert_eq(_count_snaps_with_pose(room, "lying"), 3)


func test_garden_party_has_two_snap_points() -> void:
	var room: Node2D = preload("res://scenes/rooms/home/GardenParty.tscn").instantiate() as Node2D
	add_child_autofree(room)
	assert_eq(_count_snaps(room), 2)


func test_garden_party_all_snaps_are_sitting() -> void:
	var room: Node2D = preload("res://scenes/rooms/home/GardenParty.tscn").instantiate() as Node2D
	add_child_autofree(room)
	assert_eq(_count_snaps_with_pose(room, "sitting"), 2)
