summaryrefslogtreecommitdiff
path: root/Tests/ComponentTests/test_StartMenu.gd
blob: 8563a67b1931b87b539b8c76c243beb23b9e27f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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_Credits_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)

func test_Credits_button_label_is_localized():
	var label = _instance.CreditsButton.text
	assert_ne(label, tr(label))

func test_Quit_button_label_is_localized():
	var label = _instance.QuitButton.text
	assert_ne(label, tr(label))

func test_Start_button_label_is_localize():
	var label = _instance.StartButton.text
	assert_ne(label, tr(label))