diff options
| author | Sophia Pearson <codergal89@gmail.com> | 2022-05-27 23:52:37 +0200 |
|---|---|---|
| committer | Sophia Pearson <codergal89@gmail.com> | 2022-05-27 23:52:37 +0200 |
| commit | 0477b9ab34817165ac7b11ad77a6740995f55892 (patch) | |
| tree | 5721a9c7a1f0437fb8c526544bc7e63a0ea9cc66 /Tests/ComponentTests/test_StartMenu.gd | |
| parent | 1010b138a0e52f860ef73d5552b0be236573c46b (diff) | |
| download | texty-0477b9ab34817165ac7b11ad77a6740995f55892.tar.xz texty-0477b9ab34817165ac7b11ad77a6740995f55892.zip | |
gui: add signals to start menu
Diffstat (limited to 'Tests/ComponentTests/test_StartMenu.gd')
| -rw-r--r-- | Tests/ComponentTests/test_StartMenu.gd | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Tests/ComponentTests/test_StartMenu.gd b/Tests/ComponentTests/test_StartMenu.gd new file mode 100644 index 0000000..194a2dc --- /dev/null +++ b/Tests/ComponentTests/test_StartMenu.gd @@ -0,0 +1,48 @@ +extends GutTest + +const Scene = preload('res://Scenes/StartMenu.tscn') +const StartMenu = preload('res://Scripts/StartMenu.cs') + +var _instance: StartMenu = null +var _sender = InputSender.new(Input) +const _quit_game = 'QuitGame' +const _show_credits = 'ShowCredits' +const _start_game = 'StartGame' + +func before_each(): + _instance = add_child_autofree(Scene.instance()) + yield(_instance, 'visibility_changed') + +func after_each(): + _sender.release_all() + _sender.clear() + +func test_can_instantiate(): + assert_not_null(_instance) + +func test_StartButton_is_focused_when_scene_becomes_visible(): + assert_true(_instance.StartButton.has_focus()) + +func test_has_QuitGame_signal(): + assert_has_signal(_instance, _quit_game) + +func test_has_ShowCredits_signal(): + assert_has_signal(_instance, _show_credits) + +func test_has_StartGame_signal(): + assert_has_signal(_instance, _start_game) + +func test_clicking_the_Start_button_emits_ShowCredits_signal(): + watch_signals(_instance) + yield(UiHelpers.click_control(_sender, _instance.CreditsButton), 'idle') + assert_signal_emitted(_instance, _show_credits) + +func test_clicking_the_Quit_button_emits_QuitGame_signal(): + watch_signals(_instance) + yield(UiHelpers.click_control(_sender, _instance.QuitButton), 'idle') + assert_signal_emitted(_instance, _quit_game) + +func test_clicking_the_Start_button_emits_StartGame_signal(): + watch_signals(_instance) + yield(UiHelpers.click_control(_sender, _instance.StartButton), 'idle') + assert_signal_emitted(_instance, _start_game) |
