blob: d619b21a0c0a64a488b0baf5b89832e9e7b28565 (
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
|
extends GutTest
const Scene = preload('res://Scenes/Game/Game.tscn')
const Game = preload('res://Scripts/Game/Game.cs')
const InputArea = preload('res://Scripts/Game/CommandInputArea.cs')
const OutputArea = preload('res://Scripts/Terminal/OutputArea.cs')
var _instance: Game = null
var _sender = InputSender.new(Input)
func _get_output_area() -> OutputArea:
return _instance.get_node('%OutputArea') as OutputArea
func _get_input_area() -> InputArea:
return _instance.get_node('%InputArea') as InputArea
func before_each():
_instance = add_child_autofree(Scene.instantiate())
func after_each():
_sender.release_all()
_sender.clear()
func before_all():
_sender.set_auto_flush_input(true)
func after_all():
assert_no_new_orphans()
func test_can_instantiate():
assert_not_null(_instance)
func test_has_OutputArea():
assert_not_null(_get_output_area())
func test_OutputArea_is_empty_after_instantiation():
assert_true(_get_output_area().TextBlocks.is_empty())
func test_has_InputArea():
assert_not_null(_get_input_area())
func test_InputArea_has_focus_after_instantiation():
assert_true(_get_input_area().HasFocus)
func test_after_submitting_some_text_via_InputArea_OutputArea_is_not_empty():
var textInput = _get_input_area().get_node('%TextInput')
textInput.text = 'this is a test'
UiHelpers.press_key(_sender, KEY_ENTER)
assert_false(_get_output_area().TextBlocks.is_empty())
|