From 23c58092c6bd12e12224f5407e8dbe63a6adece6 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sat, 20 Jun 2020 05:55:13 -0700 Subject: [PATCH] Renamed test [skip ci] --- test/autocomplete_test.rb | 81 --------------------------------------------------------------------------------- test/partial_match_test.rb | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 81 deletions(-) delete mode 100644 test/autocomplete_test.rb create mode 100644 test/partial_match_test.rb diff --git a/test/autocomplete_test.rb b/test/autocomplete_test.rb deleted file mode 100644 index 0bee242..0000000 --- a/test/autocomplete_test.rb +++ /dev/null @@ -1,81 +0,0 @@ -require_relative "test_helper" - -class AutocompleteTest < Minitest::Test - def test_autocomplete - store_names ["Hummus"] - assert_search "hum", ["Hummus"], match: :text_start - end - - def test_autocomplete_two_words - store_names ["Organic Hummus"] - assert_search "hum", [], match: :text_start - end - - def test_autocomplete_fields - store_names ["Hummus"] - assert_search "hum", ["Hummus"], match: :text_start, fields: [:name] - end - - def test_text_start - store_names ["Where in the World is Carmen San Diego"] - assert_search "where in the world is", ["Where in the World is Carmen San Diego"], fields: [{name: :text_start}] - assert_search "in the world", [], fields: [{name: :text_start}] - end - - def test_text_middle - store_names ["Where in the World is Carmen San Diego"] - assert_search "where in the world is", ["Where in the World is Carmen San Diego"], fields: [{name: :text_middle}] - assert_search "n the wor", ["Where in the World is Carmen San Diego"], fields: [{name: :text_middle}] - assert_search "men san diego", ["Where in the World is Carmen San Diego"], fields: [{name: :text_middle}] - assert_search "world carmen", [], fields: [{name: :text_middle}] - end - - def test_text_end - store_names ["Where in the World is Carmen San Diego"] - assert_search "men san diego", ["Where in the World is Carmen San Diego"], fields: [{name: :text_end}] - assert_search "carmen san", [], fields: [{name: :text_end}] - end - - def test_word_start - store_names ["Where in the World is Carmen San Diego"] - assert_search "car san wor", ["Where in the World is Carmen San Diego"], fields: [{name: :word_start}] - end - - def test_word_middle - store_names ["Where in the World is Carmen San Diego"] - assert_search "orl", ["Where in the World is Carmen San Diego"], fields: [{name: :word_middle}] - end - - def test_word_end - store_names ["Where in the World is Carmen San Diego"] - assert_search "rld men ego", ["Where in the World is Carmen San Diego"], fields: [{name: :word_end}] - end - - def test_word_start_multiple_words - store_names ["Dark Grey", "Dark Blue"] - assert_search "dark grey", ["Dark Grey"], fields: [{name: :word_start}] - end - - def test_word_start_exact - store_names ["Back Scratcher", "Backpack"] - assert_order "back", ["Back Scratcher", "Backpack"], fields: [{name: :word_start}] - end - - def test_word_start_exact_martin - store_names ["Martina", "Martin"] - assert_order "martin", ["Martin", "Martina"], fields: [{name: :word_start}] - end - - # TODO find a better place - - def test_exact - store_names ["hi@example.org"] - assert_search "hi@example.org", ["hi@example.org"], fields: [{name: :exact}] - end - - def test_exact_case - store_names ["Hello"] - assert_search "hello", [], fields: [{name: :exact}] - assert_search "Hello", ["Hello"], fields: [{name: :exact}] - end -end diff --git a/test/partial_match_test.rb b/test/partial_match_test.rb new file mode 100644 index 0000000..78fa1f1 --- /dev/null +++ b/test/partial_match_test.rb @@ -0,0 +1,81 @@ +require_relative "test_helper" + +class PartialMatchTest < Minitest::Test + def test_autocomplete + store_names ["Hummus"] + assert_search "hum", ["Hummus"], match: :text_start + end + + def test_autocomplete_two_words + store_names ["Organic Hummus"] + assert_search "hum", [], match: :text_start + end + + def test_autocomplete_fields + store_names ["Hummus"] + assert_search "hum", ["Hummus"], match: :text_start, fields: [:name] + end + + def test_text_start + store_names ["Where in the World is Carmen San Diego"] + assert_search "where in the world is", ["Where in the World is Carmen San Diego"], fields: [{name: :text_start}] + assert_search "in the world", [], fields: [{name: :text_start}] + end + + def test_text_middle + store_names ["Where in the World is Carmen San Diego"] + assert_search "where in the world is", ["Where in the World is Carmen San Diego"], fields: [{name: :text_middle}] + assert_search "n the wor", ["Where in the World is Carmen San Diego"], fields: [{name: :text_middle}] + assert_search "men san diego", ["Where in the World is Carmen San Diego"], fields: [{name: :text_middle}] + assert_search "world carmen", [], fields: [{name: :text_middle}] + end + + def test_text_end + store_names ["Where in the World is Carmen San Diego"] + assert_search "men san diego", ["Where in the World is Carmen San Diego"], fields: [{name: :text_end}] + assert_search "carmen san", [], fields: [{name: :text_end}] + end + + def test_word_start + store_names ["Where in the World is Carmen San Diego"] + assert_search "car san wor", ["Where in the World is Carmen San Diego"], fields: [{name: :word_start}] + end + + def test_word_middle + store_names ["Where in the World is Carmen San Diego"] + assert_search "orl", ["Where in the World is Carmen San Diego"], fields: [{name: :word_middle}] + end + + def test_word_end + store_names ["Where in the World is Carmen San Diego"] + assert_search "rld men ego", ["Where in the World is Carmen San Diego"], fields: [{name: :word_end}] + end + + def test_word_start_multiple_words + store_names ["Dark Grey", "Dark Blue"] + assert_search "dark grey", ["Dark Grey"], fields: [{name: :word_start}] + end + + def test_word_start_exact + store_names ["Back Scratcher", "Backpack"] + assert_order "back", ["Back Scratcher", "Backpack"], fields: [{name: :word_start}] + end + + def test_word_start_exact_martin + store_names ["Martina", "Martin"] + assert_order "martin", ["Martin", "Martina"], fields: [{name: :word_start}] + end + + # TODO find a better place + + def test_exact + store_names ["hi@example.org"] + assert_search "hi@example.org", ["hi@example.org"], fields: [{name: :exact}] + end + + def test_exact_case + store_names ["Hello"] + assert_search "hello", [], fields: [{name: :exact}] + assert_search "Hello", ["Hello"], fields: [{name: :exact}] + end +end -- libgit2 0.21.0