## Tests for AudioManager — floor derivation, no-op guard, SFX key validation.
extends GutTest


func before_each() -> void:
	AudioManager._current_floor = -1
	AudioManager._is_crossfading = false


func test_derive_floor_floor0_reception() -> void:
	assert_eq(AudioManager._derive_floor_from_room("reception"), 0)


func test_derive_floor_floor0_all_rooms() -> void:
	assert_eq(AudioManager._derive_floor_from_room("giftshop"), 0)
	assert_eq(AudioManager._derive_floor_from_room("restaurant"), 0)
	assert_eq(AudioManager._derive_floor_from_room("emergency"), 0)


func test_derive_floor_floor1_all_rooms() -> void:
	assert_eq(AudioManager._derive_floor_from_room("xray"), 1)
	assert_eq(AudioManager._derive_floor_from_room("pharmacy"), 1)
	assert_eq(AudioManager._derive_floor_from_room("lab"), 1)
	assert_eq(AudioManager._derive_floor_from_room("patient_rooms"), 1)


func test_derive_floor_floor2_all_rooms() -> void:
	assert_eq(AudioManager._derive_floor_from_room("ultrasound"), 2)
	assert_eq(AudioManager._derive_floor_from_room("delivery_room"), 2)
	assert_eq(AudioManager._derive_floor_from_room("nursery"), 2)


func test_derive_floor_garden() -> void:
	assert_eq(AudioManager._derive_floor_from_room("garden_party"), 3)


func test_derive_floor_unknown_returns_minus_one() -> void:
	assert_eq(AudioManager._derive_floor_from_room("unknown_room"), -1)
	assert_eq(AudioManager._derive_floor_from_room(""), -1)


func test_get_current_floor_starts_at_minus_one() -> void:
	assert_eq(AudioManager.get_current_floor(), -1)


func test_play_floor_music_same_floor_is_noop() -> void:
	AudioManager._current_floor = 0
	AudioManager.play_floor_music(0)
	assert_eq(AudioManager.get_current_floor(), 0)


func test_play_sfx_unknown_key_does_not_crash() -> void:
	AudioManager.play_sfx("nonexistent_event_xyz")
	pass


func test_sfx_map_has_all_seven_keys() -> void:
	assert_true(AudioManager._SFX_MAP.has("chest_tap"))
	assert_true(AudioManager._SFX_MAP.has("item_spawn"))
	assert_true(AudioManager._SFX_MAP.has("item_drag_start"))
	assert_true(AudioManager._SFX_MAP.has("item_drop_hand"))
	assert_true(AudioManager._SFX_MAP.has("item_drop_outfit"))
	assert_true(AudioManager._SFX_MAP.has("item_return_chest"))
	assert_true(AudioManager._SFX_MAP.has("item_drop_floor"))


func test_music_map_has_all_four_floors() -> void:
	assert_true(AudioManager._MUSIC_MAP.has(0))
	assert_true(AudioManager._MUSIC_MAP.has(1))
	assert_true(AudioManager._MUSIC_MAP.has(2))
	assert_true(AudioManager._MUSIC_MAP.has(3))


func test_default_music_volume_constant_is_0_6() -> void:
	assert_eq(AudioManager.DEFAULT_MUSIC_VOLUME, 0.6)


func test_sfx_map_has_all_interactive_object_keys() -> void:
	assert_true(AudioManager._SFX_MAP.has("xray_scan"))
	assert_true(AudioManager._SFX_MAP.has("tea_pour"))
	assert_true(AudioManager._SFX_MAP.has("cradle_rock"))
	assert_true(AudioManager._SFX_MAP.has("gift_open"))
	assert_true(AudioManager._SFX_MAP.has("ambulance_siren"))
	assert_true(AudioManager._SFX_MAP.has("delivery_cheer"))
	assert_true(AudioManager._SFX_MAP.has("object_tap"))


func test_sfx_map_has_all_character_keys() -> void:
	assert_true(AudioManager._SFX_MAP.has("character_pickup"))
	assert_true(AudioManager._SFX_MAP.has("character_place"))
	assert_true(AudioManager._SFX_MAP.has("character_tap"))
