summaryrefslogtreecommitdiff
path: root/Tests/Game/test_Game.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/Game/test_Game.gd')
-rw-r--r--Tests/Game/test_Game.gd50
1 files changed, 50 insertions, 0 deletions
diff --git a/Tests/Game/test_Game.gd b/Tests/Game/test_Game.gd
new file mode 100644
index 0000000..427d28c
--- /dev/null
+++ b/Tests/Game/test_Game.gd
@@ -0,0 +1,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.instance())
+
+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.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.empty())