diff options
Diffstat (limited to 'Tests/ComponentTests')
| -rw-r--r-- | Tests/ComponentTests/ParserTests/CommandParserTestBase.gd | 29 | ||||
| -rw-r--r-- | Tests/ComponentTests/ParserTests/test_CommandParser.gd | 9 | ||||
| -rw-r--r-- | Tests/ComponentTests/ParserTests/test_LookCommand.gd | 55 | ||||
| -rw-r--r-- | Tests/ComponentTests/test_InputContainer.gd | 80 | ||||
| -rw-r--r-- | Tests/ComponentTests/test_OutputRow.gd | 46 | ||||
| -rw-r--r-- | Tests/ComponentTests/test_StartMenu.gd | 60 |
6 files changed, 0 insertions, 279 deletions
diff --git a/Tests/ComponentTests/ParserTests/CommandParserTestBase.gd b/Tests/ComponentTests/ParserTests/CommandParserTestBase.gd deleted file mode 100644 index 6e452cb..0000000 --- a/Tests/ComponentTests/ParserTests/CommandParserTestBase.gd +++ /dev/null @@ -1,29 +0,0 @@ -extends GutTest - -class_name CommandParserTestBase - -const CommandParser = preload("res://Scripts/CommandParser.cs") - -var _instance: CommandParser - -func _to_bits(number: int, bits: int) -> Array: - var result = [] - for bit in bits: - result.append(number & 1) - number = number >> 1 - return result - -func before_each(): - _instance = autofree(CommandParser.new()) - -func generate_capitalization_permutations(text: String) -> Array: - var result = [] - - for permutation in pow(2, text.length()): - var mask = _to_bits(permutation, text.length()) - var copy = String(text) - for index in len(mask): - if mask[index] == 1: - copy[index] = copy[index].to_upper() - result.append(copy) - return result; diff --git a/Tests/ComponentTests/ParserTests/test_CommandParser.gd b/Tests/ComponentTests/ParserTests/test_CommandParser.gd deleted file mode 100644 index bdb14a6..0000000 --- a/Tests/ComponentTests/ParserTests/test_CommandParser.gd +++ /dev/null @@ -1,9 +0,0 @@ -extends CommandParserTestBase - -const Command = preload("res://Scripts/Command.cs") - -func parse(input: String) -> Command: - return autofree(_instance.TryParse(input)) - -func test_parsing_the_empty_string_returns_null(): - assert_null(parse('')) diff --git a/Tests/ComponentTests/ParserTests/test_LookCommand.gd b/Tests/ComponentTests/ParserTests/test_LookCommand.gd deleted file mode 100644 index 32268b0..0000000 --- a/Tests/ComponentTests/ParserTests/test_LookCommand.gd +++ /dev/null @@ -1,55 +0,0 @@ -extends CommandParserTestBase - -const LookCommand = preload("res://Scripts/Commands/LookCommand.cs") - -var _around_permutations = generate_capitalization_permutations('around') -var _at_permutations = generate_capitalization_permutations('at') -var _look_permutations = generate_capitalization_permutations('look') - -func parse(input: String) -> LookCommand: - return autofree(_instance.TryParse(input)) - -func test_parsing_look_command_without_an_argument_returns_non_null(): - assert_not_null(parse('look')) - -func test_parsing_look_command_is_case_insensitive(permutation=use_parameters(_look_permutations)): - assert_not_null(parse(permutation)) - -func test_parsing_look_command_without_an_argument_returns_look_command_with_an_emtpy_target(): - assert_eq('', parse('look').Target) - -func test_parsing_look_at_command_is_case_insensitive(permutation=use_parameters(_at_permutations)): - assert_not_null(parse('look ' + permutation)) - -func test_parsing_look_at_command_without_further_arguments_returns_look_command_with_an_emtpy_target(): - assert_eq('', parse('look at').Target) - -func test_parsing_look_at_command_without_further_arguments_returns_look_command_with_non_null_modifier(): - assert_not_null(parse('look at').Modifier) - -func test_parsing_look_at_command_without_further_arguments_returns_look_command_with_at_modifier(): - assert_eq('At', parse('look at').ModifierAsString) - -func test_parsing_look_at_command_with_more_arguments_returns_look_command_with_non_empty_target(): - assert_ne('', parse('look at door on the left').Target) - -func test_parsing_look_at_command_with_an_additional_argument_returns_look_command_with_the_additional_argument_as_the_target(): - assert_eq('window', parse('look at window').Target) - -func test_parsing_look_at_command_with_multiple_additional_arguments_returns_look_command_with_the_additional_arguments_as_the_target(): - assert_eq('table near the door', parse('look at table near the door').Target) - -func test_parsing_look_around_command_is_case_insensitive(permutation=use_parameters(_around_permutations)): - assert_not_null(parse('look ' + permutation)) - -func test_parsing_look_around_command_without_further_arguments_returns_look_command_with_an_empty_target(): - assert_eq('', parse('look around').Target) - -func test_parsing_look_around_command_without_further_arguments_returns_look_command_with_non_null_modifier(): - assert_not_null(parse('look around').Modifier) - -func test_parsing_look_around_command_without_further_arguments_returns_look_command_with_around_modifier(): - assert_eq('Around', parse('look around').ModifierAsString) - -func test_parsing_look_around_command_ignores_all_additional_arguments(): - assert_eq('', parse('look around the room').Target) diff --git a/Tests/ComponentTests/test_InputContainer.gd b/Tests/ComponentTests/test_InputContainer.gd deleted file mode 100644 index 5289903..0000000 --- a/Tests/ComponentTests/test_InputContainer.gd +++ /dev/null @@ -1,80 +0,0 @@ -extends GutTest - -const Scene = preload('res://Scenes/InputContainer.tscn') -const InputContainer = preload('res://Scripts/InputContainer.cs') - -var _instance: InputContainer = null -var _sender = InputSender.new(Input) -const _test_data = 'This is some test data' -const _input_submitted = 'InputSubmitted' - -func _set_input_text(text): - _instance.InputField.text = text - _instance.InputField.emit_signal('text_changed', _instance.InputField.text) - -func before_each(): - _instance = add_child_autofree(Scene.instance()) - yield(yield_frames(1), YIELD) - -func after_each(): - _sender.release_all() - _sender.clear() - -func test_can_instantiate(): - assert_not_null(_instance) - -func test_has_InputSubmitted_signal(): - assert_has_signal(_instance, _input_submitted) - -func test_has_InputField(): - assert_not_null(_instance.InputField) - -func test_InputField_has_focus_when_scene_is_instantiated(): - assert_true(_instance.InputField.has_focus()) - -func test_InputSubmitted_signal_is_not_emitted_when_enter_is_pressed_without_text_in_InputField(): - watch_signals(_instance) - yield(UiHelpers.press_key(_sender, KEY_ENTER), 'idle') - assert_signal_not_emitted(_instance, _input_submitted) - -func test_InputSubmitted_signal_is_emitted_when_enter_is_pressed_with_text_in_InputField(): - watch_signals(_instance) - _set_input_text(_test_data) - yield(UiHelpers.press_key(_sender, KEY_ENTER), 'idle') - assert_signal_emitted(_instance, _input_submitted) - -func test_InputField_is_empty_after_text_is_submitted(): - _set_input_text(_test_data) - yield(UiHelpers.press_key(_sender, KEY_ENTER), 'idle') - assert_eq(_instance.InputField.text, '') - -func test_has_SubmitButton(): - assert_not_null(_instance.SubmitButton) - -func test_SubmitButton_is_disable_after_scene_was_instantiated(): - assert_true(_instance.SubmitButton.disabled) - -func test_SubmitButton_is_disabled_when_InputField_is_set_to_empty(): - _set_input_text('') - assert_true(_instance.SubmitButton.disabled) - -func test_SubmitButton_is_enabled_when_InputField_is_set_to_some_text(): - _set_input_text(_test_data) - assert_false(_instance.SubmitButton.disabled) - -func test_InputSubmitted_signal_is_not_emitted_when_SubmitButton_is_clicked_without_text_in_InputField(): - watch_signals(_instance) - _set_input_text('') - yield(UiHelpers.click_control(_sender, _instance.SubmitButton), 'idle') - assert_signal_not_emitted(_instance, _input_submitted) - -func test_InputSubmitted_signal_is_emitted_when_SubmitButton_is_clicked_with_text_in_InputField(): - watch_signals(_instance) - _set_input_text(_test_data) - yield(UiHelpers.click_control(_sender, _instance.SubmitButton), 'idle') - assert_signal_emitted(_instance, _input_submitted) - -func test_InputField_is_empty_after_text_is_submitted_via_SubmitButton(): - _set_input_text(_test_data) - yield(UiHelpers.click_control(_sender, _instance.SubmitButton), 'idle') - assert_eq(_instance.InputField.text, '') diff --git a/Tests/ComponentTests/test_OutputRow.gd b/Tests/ComponentTests/test_OutputRow.gd deleted file mode 100644 index 6e782de..0000000 --- a/Tests/ComponentTests/test_OutputRow.gd +++ /dev/null @@ -1,46 +0,0 @@ -extends GutTest - -const Scene = preload("res://Scenes/OutputRow.tscn") -const OutputRow = preload("res://Scripts/OutputRow.cs") - -const _input_text_changed = 'InputTextChanged' -const _output_text_changed = 'OutputTextChanged' -const _test_data = 'This is some test data' -var _instance: OutputRow = null - - -func before_each(): - _instance = add_child_autofree(Scene.instance()) - -func test_can_instantiate(): - assert_not_null(_instance) - -func test_InputText_is_empty_after_instantiation(): - assert_eq(_instance.InputText, '') - -func test_OutputText_is_empty_after_instantiation(): - assert_eq(_instance.OutputText, '') - -func test_Input_contains_text_assigned_to_InputText(): - _instance.InputText = _test_data - assert_eq(_instance.Input.text, _test_data) - -func test_Output_contains_text_assigned_to_OutputText(): - _instance.OutputText = _test_data - assert_eq(_instance.Output.text, _test_data) - -func test_has_InputTextChanged_signal(): - assert_has_signal(_instance, _input_text_changed) - -func test_has_OutputTextChanged_signal(): - assert_has_signal(_instance, _output_text_changed) - -func test_InputTextChanged_signal_is_emitted_when_setting_InputText(): - watch_signals(_instance) - _instance.InputText = _test_data - assert_signal_emitted(_instance, _input_text_changed) - -func test_OutputTextChanged_signal_is_emitted_when_setting_OutputText(): - watch_signals(_instance) - _instance.OutputText = _test_data - assert_signal_emitted(_instance, _output_text_changed) diff --git a/Tests/ComponentTests/test_StartMenu.gd b/Tests/ComponentTests/test_StartMenu.gd deleted file mode 100644 index 8563a67..0000000 --- a/Tests/ComponentTests/test_StartMenu.gd +++ /dev/null @@ -1,60 +0,0 @@ -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)) |
