## Tests verifying SnapPoints exist in all 1.OG 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 test_xray_has_one_snap_point() -> void:
	var room: Node2D = preload("res://scenes/rooms/floor1/XRay.tscn").instantiate() as Node2D
	add_child_autofree(room)
	assert_eq(_count_snaps(room), 1)


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


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


func test_pharmacy_snap_is_sitting() -> void:
	var room: Node2D = preload("res://scenes/rooms/floor1/Pharmacy.tscn").instantiate() as Node2D
	add_child_autofree(room)
	assert_eq(_count_snaps_with_pose(room, "sitting"), 1)


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


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


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


func test_patient_room_all_snaps_are_lying() -> void:
	var room: Node2D = preload("res://scenes/rooms/floor1/PatientRoom.tscn").instantiate() as Node2D
	add_child_autofree(room)
	assert_eq(_count_snaps_with_pose(room, "lying"), 2)
