test(room-navigator): add missing is_at_home and go_to_hospital tests
Adds 7 new test cases covering home/hospital navigation state: - is_at_home() initial state and transitions - go_to_home() with idempotence check - go_to_hospital() state restoration and guards - is_at_home flag cleanup on room navigation Implements corresponding methods in RoomNavigator: - is_at_home(): Returns home state - go_to_home(): Navigates to home (0,0) and saves hospital position - go_to_hospital(): Returns to previously saved hospital location - _go_to_room_internal(): Helper to avoid flag interference All 34 tests passing. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -89,3 +89,52 @@ func test_multiple_room_changes_update_state() -> void:
|
||||
_nav.go_to_room(2, 3)
|
||||
assert_eq(_nav.get_current_floor(), 2)
|
||||
assert_eq(_nav.get_current_room(), 3)
|
||||
|
||||
|
||||
func test_is_at_home_starts_false() -> void:
|
||||
assert_false(_nav.is_at_home())
|
||||
|
||||
|
||||
func test_go_to_home_sets_is_at_home_true() -> void:
|
||||
_nav.go_to_home()
|
||||
assert_true(_nav.is_at_home())
|
||||
|
||||
|
||||
func test_go_to_home_twice_is_noop_on_second_call() -> void:
|
||||
_nav.go_to_home()
|
||||
var camera_pos: Vector2 = _camera.position
|
||||
_nav.go_to_home()
|
||||
assert_eq(_camera.position, camera_pos)
|
||||
|
||||
|
||||
func test_go_to_hospital_clears_is_at_home() -> void:
|
||||
_nav.go_to_home()
|
||||
_nav.go_to_hospital()
|
||||
assert_false(_nav.is_at_home())
|
||||
|
||||
|
||||
func test_go_to_hospital_restores_last_floor() -> void:
|
||||
_nav.go_to_room(1, 2)
|
||||
_nav.go_to_home()
|
||||
_nav.go_to_hospital()
|
||||
assert_eq(_nav.get_current_floor(), 1)
|
||||
|
||||
|
||||
func test_go_to_hospital_restores_last_room() -> void:
|
||||
_nav.go_to_room(1, 2)
|
||||
_nav.go_to_home()
|
||||
_nav.go_to_hospital()
|
||||
assert_eq(_nav.get_current_room(), 2)
|
||||
|
||||
|
||||
func test_go_to_hospital_when_not_at_home_is_noop() -> void:
|
||||
_nav.go_to_room(1, 2)
|
||||
var camera_pos: Vector2 = _camera.position
|
||||
_nav.go_to_hospital()
|
||||
assert_eq(_camera.position, camera_pos)
|
||||
|
||||
|
||||
func test_go_to_room_after_home_clears_is_at_home() -> void:
|
||||
_nav.go_to_home()
|
||||
_nav.go_to_room(0, 0)
|
||||
assert_false(_nav.is_at_home())
|
||||
|
||||
Reference in New Issue
Block a user