summaryrefslogtreecommitdiff
path: root/Tests/Terminal
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/Terminal')
-rw-r--r--Tests/Terminal/test_OutputArea.gd51
-rw-r--r--Tests/Terminal/test_OutputBlock.gd32
-rw-r--r--Tests/Terminal/test_StatusArea.gd32
3 files changed, 115 insertions, 0 deletions
diff --git a/Tests/Terminal/test_OutputArea.gd b/Tests/Terminal/test_OutputArea.gd
new file mode 100644
index 0000000..88beddb
--- /dev/null
+++ b/Tests/Terminal/test_OutputArea.gd
@@ -0,0 +1,51 @@
+extends GutTest
+
+const Scene = preload('res://Scenes/Terminal/OutputArea.tscn')
+const GameOutput = preload('res://Scripts/Terminal/OutputArea.cs')
+
+var _instance: GameOutput = null
+
+func _get_line_container() -> VBoxContainer:
+ return _instance.get_node('%LineContainer') as VBoxContainer
+
+func after_each():
+ yield(yield_frames(1), YIELD)
+
+func before_each():
+ var scene = Scene.instance()
+ scene.OutputBlockScene = preload('res://Scenes/Terminal/OutputBlock.tscn')
+ _instance = add_child_autofree(scene)
+
+func after_all():
+ assert_no_new_orphans()
+
+func test_can_be_instantiated():
+ assert_not_null(_instance)
+
+func test_LineContainer_is_empty_after_instantiation():
+ assert_true(_get_line_container().get_children().empty())
+
+func test_TextBlocks_is_empty_after_instantiation():
+ assert_true(_instance.TextBlocks.empty())
+
+func test_LineContainer_is_not_empty_after_calling_Push_with_a_non_empty_string_as_text():
+ _instance.Push('this is some test data')
+ assert_false(_get_line_container().get_children().empty())
+
+func test_LineContainer_is_empty_after_calling_Push_with_an_empty_string_as_text():
+ _instance.Push('')
+ assert_true(_get_line_container().get_children().empty())
+
+func test_TextBlocks_is_not_empty_after_calling_Push_with_a_non_empty_string_as_text():
+ _instance.Push('this is some test data')
+ assert_false(_instance.TextBlocks.empty())
+
+func test_TextBlocks_is_empty_after_calling_Push_with_an_empty_string_as_text():
+ _instance.Push('')
+ assert_true(_instance.TextBlocks.empty())
+
+func test_TextBlocks_contains_all_pushed_texts_in_the_push_order():
+ var texts = ['text block a', 'text block b']
+ for text in texts:
+ _instance.Push(text)
+ assert_eq(_instance.TextBlocks, texts)
diff --git a/Tests/Terminal/test_OutputBlock.gd b/Tests/Terminal/test_OutputBlock.gd
new file mode 100644
index 0000000..f586c55
--- /dev/null
+++ b/Tests/Terminal/test_OutputBlock.gd
@@ -0,0 +1,32 @@
+extends GutTest
+
+const Scene = preload("res://Scenes/Terminal/OutputBlock.tscn")
+const OutputBlock = preload("res://Scripts/Terminal/OutputBlock.cs")
+
+const _input_text_changed = 'InputTextChanged'
+const _output_text_changed = 'OutputTextChanged'
+const _test_data = 'This is some test data'
+var _instance: OutputBlock = null
+
+
+func before_each():
+ _instance = add_child_autofree(Scene.instance())
+
+func after_all():
+ assert_no_new_orphans()
+
+func test_can_instantiate():
+ assert_not_null(_instance)
+
+func test_Content_is_empty_after_instantiation():
+ assert_eq(_instance.Content, '')
+
+func test_ContentLabel_bbcode_enabled_is_enabled_after_instantiation():
+ assert_true(_instance.get_node('ContentLabel').bbcode_enabled)
+
+func test_ContentLabel_is_empty_after_instantiation():
+ assert_eq(_instance.get_node('ContentLabel').bbcode_text, '')
+
+func test_setting_Content_sets_ContentLabel_bbcode_text():
+ _instance.Content = 'test'
+ assert_eq(_instance.get_node('ContentLabel').bbcode_text, 'test')
diff --git a/Tests/Terminal/test_StatusArea.gd b/Tests/Terminal/test_StatusArea.gd
new file mode 100644
index 0000000..8277210
--- /dev/null
+++ b/Tests/Terminal/test_StatusArea.gd
@@ -0,0 +1,32 @@
+extends GutTest
+
+const Scene = preload("res://Scenes/Terminal/StatusArea.tscn")
+const StatusLine = preload("res://Scripts/Terminal/StatusArea.cs")
+
+var _instance: StatusLine = null
+
+func _get_title_label() -> RichTextLabel:
+ return _instance.get_node('%TitleLabel') as RichTextLabel
+
+func before_each():
+ _instance = add_child_autofree(Scene.instance())
+
+func after_all():
+ assert_no_new_orphans()
+
+func test_can_be_instantiated():
+ assert_not_null(_instance)
+
+func test_Title_is_empty_after_instantiation():
+ assert_true(_instance.Title.empty())
+
+func test_TitleLabel_is_empty_after_instantiation():
+ assert_true(_get_title_label().text.empty())
+
+func test_setting_Title_to_a_non_empty_string_makes_TitleLable_non_empty():
+ _instance.Title = 'this is a test title'
+ assert_false(_get_title_label().text.empty())
+
+func test_setting_Title_sets_the_bbcode_text_property_on_TitleLabel():
+ _instance.Title = '[wave]this is a test title[/wave]'
+ assert_false(_get_title_label().bbcode_text.empty())