Files
code_of_conquest_dnd/client/tests/unit/test_title_screen.gd

52 lines
1.2 KiB
GDScript

extends "res://addons/gut/test.gd"
const SCENE := "res://scenes/title/TitleScreen.tscn"
func _title() -> TitleScreen:
var t = load(SCENE).instantiate()
add_child_autofree(t) # runs _ready()
return t
func _index_of(t: TitleScreen, action: StringName) -> int:
for i in range(t._rows.size()):
if t._rows[i].get_meta("action") == action:
return i
return -1
func test_six_menu_rows_each_with_an_action():
var t := _title()
assert_eq(t._rows.size(), 6)
for row in t._rows:
assert_true(row.has_meta("action"))
func test_down_moves_selection():
var t := _title()
assert_eq(t._sel, 0)
t._move(1)
assert_eq(t._sel, 1)
func test_up_from_first_wraps_to_last():
var t := _title()
t._move(-1)
assert_eq(t._sel, t._rows.size() - 1)
func test_new_game_and_quit_emit_their_action():
var t := _title()
# Title is emit-only now: no internal handler to isolate. Just watch the emit.
watch_signals(t)
t._activate(_index_of(t, &"new_game"))
assert_signal_emitted_with_parameters(t, "menu_activated", [&"new_game"])
t._activate(_index_of(t, &"quit"))
assert_signal_emitted_with_parameters(t, "menu_activated", [&"quit"])
func test_footer_shows_version():
var t := _title()
assert_string_contains(t._footer_left.text, Version.new().string())