63 lines
1.7 KiB
GDScript
63 lines
1.7 KiB
GDScript
extends GdUnitTestSuite
|
|
|
|
const SearchWindowScript: GDScript = preload("res://SearchWindow.gd")
|
|
|
|
var _search: Control
|
|
|
|
|
|
func before_test() -> void:
|
|
_search = auto_free(SearchWindowScript.new())
|
|
_search.set_soundtracks([
|
|
"Chrono Trigger",
|
|
"Final Fantasy VI",
|
|
"Mario & Luigi: Superstar Saga",
|
|
"Pokémon Red",
|
|
"Q*bert",
|
|
"Super Mario 64",
|
|
"The Legend of Zelda: A Link to the Past",
|
|
])
|
|
|
|
|
|
func test_plain_text_matches_case_insensitively() -> void:
|
|
assert_array(_search.find_matches("chrono")).contains_exactly(["Chrono Trigger"])
|
|
|
|
|
|
func test_contains_matches_come_before_letter_order_matches() -> void:
|
|
var matches: Array[String] = _search.find_matches("mario")
|
|
|
|
assert_array(matches).contains_exactly([
|
|
"Mario & Luigi: Superstar Saga",
|
|
"Super Mario 64",
|
|
])
|
|
|
|
|
|
func test_ignores_spaces() -> void:
|
|
assert_array(_search.find_matches("finalfantasy")).contains_exactly(["Final Fantasy VI"])
|
|
|
|
|
|
func test_and_matches_ampersand() -> void:
|
|
assert_array(_search.find_matches("mario and luigi")).contains(["Mario & Luigi: Superstar Saga"])
|
|
|
|
|
|
func test_accented_letters_match_plain_letters() -> void:
|
|
assert_array(_search.find_matches("pokemon")).contains_exactly(["Pokémon Red"])
|
|
|
|
|
|
func test_letters_in_order_match_abbreviations() -> void:
|
|
assert_array(_search.find_matches("lozlttp")).contains_exactly([
|
|
"The Legend of Zelda: A Link to the Past",
|
|
])
|
|
|
|
|
|
func test_regex_characters_are_matched_literally() -> void:
|
|
assert_array(_search.find_matches("q*b")).contains_exactly(["Q*bert"])
|
|
|
|
|
|
func test_no_matches() -> void:
|
|
assert_array(_search.find_matches("metroid")).is_empty()
|
|
|
|
|
|
func test_clean_term() -> void:
|
|
assert_str(_search.clean_term("Rock 'n Roll Racing")).is_equal("rockandrollracing")
|
|
assert_str(_search.clean_term("Ys I & II")).is_equal("ysiandii")
|