Commit 03bb3fff07740d6198438bd808792dd21f8742c3

Authored by Andrew Kane
1 parent f50e59f5

Renamed test files

test/boost_test.rb 0 → 100644
@@ -0,0 +1,41 @@ @@ -0,0 +1,41 @@
  1 +require_relative "test_helper"
  2 +
  3 +class TestBoost < Minitest::Unit::TestCase
  4 +
  5 + # conversions
  6 +
  7 + def test_conversions
  8 + store [
  9 + {name: "Tomato A", conversions: {"tomato" => 1}},
  10 + {name: "Tomato B", conversions: {"tomato" => 2}},
  11 + {name: "Tomato C", conversions: {"tomato" => 3}}
  12 + ]
  13 + assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"]
  14 + end
  15 +
  16 + def test_conversions_stemmed
  17 + store [
  18 + {name: "Tomato A", conversions: {"tomato" => 1, "tomatos" => 1, "Tomatoes" => 1}},
  19 + {name: "Tomato B", conversions: {"tomato" => 2}}
  20 + ]
  21 + assert_order "tomato", ["Tomato A", "Tomato B"]
  22 + end
  23 +
  24 + # global boost
  25 +
  26 + def test_boost
  27 + store [
  28 + {name: "Organic Tomato A"},
  29 + {name: "Tomato B", orders_count: 10}
  30 + ]
  31 + assert_order "tomato", ["Tomato B", "Organic Tomato A"], boost: "orders_count"
  32 + end
  33 +
  34 + def test_boost_zero
  35 + store [
  36 + {name: "Zero Boost", orders_count: 0}
  37 + ]
  38 + assert_order "zero", ["Zero Boost"], boost: "orders_count"
  39 + end
  40 +
  41 +end
test/boosting_test.rb
@@ -1,41 +0,0 @@ @@ -1,41 +0,0 @@
1 -require_relative "test_helper"  
2 -  
3 -class TestBoosting < Minitest::Unit::TestCase  
4 -  
5 - # conversions  
6 -  
7 - def test_conversions  
8 - store [  
9 - {name: "Tomato A", conversions: {"tomato" => 1}},  
10 - {name: "Tomato B", conversions: {"tomato" => 2}},  
11 - {name: "Tomato C", conversions: {"tomato" => 3}}  
12 - ]  
13 - assert_order "tomato", ["Tomato C", "Tomato B", "Tomato A"]  
14 - end  
15 -  
16 - def test_conversions_stemmed  
17 - store [  
18 - {name: "Tomato A", conversions: {"tomato" => 1, "tomatos" => 1, "Tomatoes" => 1}},  
19 - {name: "Tomato B", conversions: {"tomato" => 2}}  
20 - ]  
21 - assert_order "tomato", ["Tomato A", "Tomato B"]  
22 - end  
23 -  
24 - # global boost  
25 -  
26 - def test_boost  
27 - store [  
28 - {name: "Organic Tomato A"},  
29 - {name: "Tomato B", orders_count: 10}  
30 - ]  
31 - assert_order "tomato", ["Tomato B", "Organic Tomato A"], boost: "orders_count"  
32 - end  
33 -  
34 - def test_boost_zero  
35 - store [  
36 - {name: "Zero Boost", orders_count: 0}  
37 - ]  
38 - assert_order "zero", ["Zero Boost"], boost: "orders_count"  
39 - end  
40 -  
41 -end  
test/match_test.rb 0 → 100644
@@ -0,0 +1,113 @@ @@ -0,0 +1,113 @@
  1 +require_relative "test_helper"
  2 +
  3 +class TestMatch < Minitest::Unit::TestCase
  4 +
  5 + # exact
  6 +
  7 + def test_match
  8 + store_names ["Whole Milk", "Fat Free Milk", "Milk"]
  9 + assert_search "milk", ["Milk", "Whole Milk", "Fat Free Milk"]
  10 + end
  11 +
  12 + def test_case
  13 + store_names ["Whole Milk", "Fat Free Milk", "Milk"]
  14 + assert_search "MILK", ["Milk", "Whole Milk", "Fat Free Milk"]
  15 + end
  16 +
  17 + def test_cheese_space_in_index
  18 + store_names ["Pepper Jack Cheese Skewers"]
  19 + assert_search "pepperjack cheese skewers", ["Pepper Jack Cheese Skewers"]
  20 + end
  21 +
  22 + def test_cheese_space_in_query
  23 + store_names ["Pepperjack Cheese Skewers"]
  24 + assert_search "pepper jack cheese skewers", ["Pepperjack Cheese Skewers"]
  25 + end
  26 +
  27 + def test_middle_token
  28 + store_names ["Dish Washer Amazing Organic Soap"]
  29 + assert_search "dish soap", ["Dish Washer Amazing Organic Soap"]
  30 + end
  31 +
  32 + def test_percent
  33 + store_names ["1% Milk", "2% Milk", "Whole Milk"]
  34 + assert_search "1%", ["1% Milk"]
  35 + end
  36 +
  37 + # ascii
  38 +
  39 + def test_jalapenos
  40 + store_names ["Jalapeño"]
  41 + assert_search "jalapeno", ["Jalapeño"]
  42 + end
  43 +
  44 + # stemming
  45 +
  46 + def test_stemming
  47 + store_names ["Whole Milk", "Fat Free Milk", "Milk"]
  48 + assert_search "milks", ["Milk", "Whole Milk", "Fat Free Milk"]
  49 + end
  50 +
  51 + # fuzzy
  52 +
  53 + def test_misspelling_sriracha
  54 + store_names ["Sriracha"]
  55 + assert_search "siracha", ["Sriracha"]
  56 + end
  57 +
  58 + def test_short_word
  59 + store_names ["Finn"]
  60 + assert_search "fin", ["Finn"]
  61 + end
  62 +
  63 + def test_edit_distance
  64 + store_names ["Bingo"]
  65 + assert_search "bin", []
  66 + assert_search "bing", ["Bingo"]
  67 + assert_search "bingoo", ["Bingo"]
  68 + assert_search "bingooo", []
  69 + assert_search "ringo", ["Bingo"]
  70 + assert_search "mango", []
  71 + store_names ["thisisareallylongword"]
  72 + assert_search "thisisareallylongwor", ["thisisareallylongword"] # missing letter
  73 + assert_search "thisisareelylongword", [] # edit distance = 2
  74 + end
  75 +
  76 + def test_misspelling_tabasco
  77 + store_names ["Tabasco"]
  78 + assert_search "tobasco", ["Tabasco"]
  79 + end
  80 +
  81 + def test_misspelling_zucchini
  82 + store_names ["Zucchini"]
  83 + assert_search "zuchini", ["Zucchini"]
  84 + end
  85 +
  86 + def test_misspelling_ziploc
  87 + store_names ["Ziploc"]
  88 + assert_search "zip lock", ["Ziploc"]
  89 + end
  90 +
  91 + # spaces
  92 +
  93 + def test_spaces_in_field
  94 + store_names ["Red Bull"]
  95 + assert_search "redbull", ["Red Bull"]
  96 + end
  97 +
  98 + def test_spaces_in_query
  99 + store_names ["Dishwasher"]
  100 + assert_search "dish washer", ["Dishwasher"]
  101 + end
  102 +
  103 + def test_spaces_three_words
  104 + store_names ["Dish Washer Soap", "Dish Washer"]
  105 + assert_search "dish washer soap", ["Dish Washer Soap"]
  106 + end
  107 +
  108 + def test_spaces_stemming
  109 + store_names ["Almond Milk"]
  110 + assert_search "almondmilks", ["Almond Milk"]
  111 + end
  112 +
  113 +end
test/matching_test.rb
@@ -1,113 +0,0 @@ @@ -1,113 +0,0 @@
1 -require_relative "test_helper"  
2 -  
3 -class TestMatching < Minitest::Unit::TestCase  
4 -  
5 - # exact  
6 -  
7 - def test_match  
8 - store_names ["Whole Milk", "Fat Free Milk", "Milk"]  
9 - assert_search "milk", ["Milk", "Whole Milk", "Fat Free Milk"]  
10 - end  
11 -  
12 - def test_case  
13 - store_names ["Whole Milk", "Fat Free Milk", "Milk"]  
14 - assert_search "MILK", ["Milk", "Whole Milk", "Fat Free Milk"]  
15 - end  
16 -  
17 - def test_cheese_space_in_index  
18 - store_names ["Pepper Jack Cheese Skewers"]  
19 - assert_search "pepperjack cheese skewers", ["Pepper Jack Cheese Skewers"]  
20 - end  
21 -  
22 - def test_cheese_space_in_query  
23 - store_names ["Pepperjack Cheese Skewers"]  
24 - assert_search "pepper jack cheese skewers", ["Pepperjack Cheese Skewers"]  
25 - end  
26 -  
27 - def test_middle_token  
28 - store_names ["Dish Washer Amazing Organic Soap"]  
29 - assert_search "dish soap", ["Dish Washer Amazing Organic Soap"]  
30 - end  
31 -  
32 - def test_percent  
33 - store_names ["1% Milk", "2% Milk", "Whole Milk"]  
34 - assert_search "1%", ["1% Milk"]  
35 - end  
36 -  
37 - # ascii  
38 -  
39 - def test_jalapenos  
40 - store_names ["Jalapeño"]  
41 - assert_search "jalapeno", ["Jalapeño"]  
42 - end  
43 -  
44 - # stemming  
45 -  
46 - def test_stemming  
47 - store_names ["Whole Milk", "Fat Free Milk", "Milk"]  
48 - assert_search "milks", ["Milk", "Whole Milk", "Fat Free Milk"]  
49 - end  
50 -  
51 - # fuzzy  
52 -  
53 - def test_misspelling_sriracha  
54 - store_names ["Sriracha"]  
55 - assert_search "siracha", ["Sriracha"]  
56 - end  
57 -  
58 - def test_short_word  
59 - store_names ["Finn"]  
60 - assert_search "fin", ["Finn"]  
61 - end  
62 -  
63 - def test_edit_distance  
64 - store_names ["Bingo"]  
65 - assert_search "bin", []  
66 - assert_search "bing", ["Bingo"]  
67 - assert_search "bingoo", ["Bingo"]  
68 - assert_search "bingooo", []  
69 - assert_search "ringo", ["Bingo"]  
70 - assert_search "mango", []  
71 - store_names ["thisisareallylongword"]  
72 - assert_search "thisisareallylongwor", ["thisisareallylongword"] # missing letter  
73 - assert_search "thisisareelylongword", [] # edit distance = 2  
74 - end  
75 -  
76 - def test_misspelling_tabasco  
77 - store_names ["Tabasco"]  
78 - assert_search "tobasco", ["Tabasco"]  
79 - end  
80 -  
81 - def test_misspelling_zucchini  
82 - store_names ["Zucchini"]  
83 - assert_search "zuchini", ["Zucchini"]  
84 - end  
85 -  
86 - def test_misspelling_ziploc  
87 - store_names ["Ziploc"]  
88 - assert_search "zip lock", ["Ziploc"]  
89 - end  
90 -  
91 - # spaces  
92 -  
93 - def test_spaces_in_field  
94 - store_names ["Red Bull"]  
95 - assert_search "redbull", ["Red Bull"]  
96 - end  
97 -  
98 - def test_spaces_in_query  
99 - store_names ["Dishwasher"]  
100 - assert_search "dish washer", ["Dishwasher"]  
101 - end  
102 -  
103 - def test_spaces_three_words  
104 - store_names ["Dish Washer Soap", "Dish Washer"]  
105 - assert_search "dish washer soap", ["Dish Washer Soap"]  
106 - end  
107 -  
108 - def test_spaces_stemming  
109 - store_names ["Almond Milk"]  
110 - assert_search "almondmilks", ["Almond Milk"]  
111 - end  
112 -  
113 -end