Commit 23c58092c6bd12e12224f5407e8dbe63a6adece6
1 parent
7cc2545d
Exists in
master
and in
5 other branches
Renamed test [skip ci]
Showing
2 changed files
with
81 additions
and
81 deletions
Show diff stats
test/autocomplete_test.rb
@@ -1,81 +0,0 @@ | @@ -1,81 +0,0 @@ | ||
1 | -require_relative "test_helper" | ||
2 | - | ||
3 | -class AutocompleteTest < Minitest::Test | ||
4 | - def test_autocomplete | ||
5 | - store_names ["Hummus"] | ||
6 | - assert_search "hum", ["Hummus"], match: :text_start | ||
7 | - end | ||
8 | - | ||
9 | - def test_autocomplete_two_words | ||
10 | - store_names ["Organic Hummus"] | ||
11 | - assert_search "hum", [], match: :text_start | ||
12 | - end | ||
13 | - | ||
14 | - def test_autocomplete_fields | ||
15 | - store_names ["Hummus"] | ||
16 | - assert_search "hum", ["Hummus"], match: :text_start, fields: [:name] | ||
17 | - end | ||
18 | - | ||
19 | - def test_text_start | ||
20 | - store_names ["Where in the World is Carmen San Diego"] | ||
21 | - assert_search "where in the world is", ["Where in the World is Carmen San Diego"], fields: [{name: :text_start}] | ||
22 | - assert_search "in the world", [], fields: [{name: :text_start}] | ||
23 | - end | ||
24 | - | ||
25 | - def test_text_middle | ||
26 | - store_names ["Where in the World is Carmen San Diego"] | ||
27 | - assert_search "where in the world is", ["Where in the World is Carmen San Diego"], fields: [{name: :text_middle}] | ||
28 | - assert_search "n the wor", ["Where in the World is Carmen San Diego"], fields: [{name: :text_middle}] | ||
29 | - assert_search "men san diego", ["Where in the World is Carmen San Diego"], fields: [{name: :text_middle}] | ||
30 | - assert_search "world carmen", [], fields: [{name: :text_middle}] | ||
31 | - end | ||
32 | - | ||
33 | - def test_text_end | ||
34 | - store_names ["Where in the World is Carmen San Diego"] | ||
35 | - assert_search "men san diego", ["Where in the World is Carmen San Diego"], fields: [{name: :text_end}] | ||
36 | - assert_search "carmen san", [], fields: [{name: :text_end}] | ||
37 | - end | ||
38 | - | ||
39 | - def test_word_start | ||
40 | - store_names ["Where in the World is Carmen San Diego"] | ||
41 | - assert_search "car san wor", ["Where in the World is Carmen San Diego"], fields: [{name: :word_start}] | ||
42 | - end | ||
43 | - | ||
44 | - def test_word_middle | ||
45 | - store_names ["Where in the World is Carmen San Diego"] | ||
46 | - assert_search "orl", ["Where in the World is Carmen San Diego"], fields: [{name: :word_middle}] | ||
47 | - end | ||
48 | - | ||
49 | - def test_word_end | ||
50 | - store_names ["Where in the World is Carmen San Diego"] | ||
51 | - assert_search "rld men ego", ["Where in the World is Carmen San Diego"], fields: [{name: :word_end}] | ||
52 | - end | ||
53 | - | ||
54 | - def test_word_start_multiple_words | ||
55 | - store_names ["Dark Grey", "Dark Blue"] | ||
56 | - assert_search "dark grey", ["Dark Grey"], fields: [{name: :word_start}] | ||
57 | - end | ||
58 | - | ||
59 | - def test_word_start_exact | ||
60 | - store_names ["Back Scratcher", "Backpack"] | ||
61 | - assert_order "back", ["Back Scratcher", "Backpack"], fields: [{name: :word_start}] | ||
62 | - end | ||
63 | - | ||
64 | - def test_word_start_exact_martin | ||
65 | - store_names ["Martina", "Martin"] | ||
66 | - assert_order "martin", ["Martin", "Martina"], fields: [{name: :word_start}] | ||
67 | - end | ||
68 | - | ||
69 | - # TODO find a better place | ||
70 | - | ||
71 | - def test_exact | ||
72 | - store_names ["hi@example.org"] | ||
73 | - assert_search "hi@example.org", ["hi@example.org"], fields: [{name: :exact}] | ||
74 | - end | ||
75 | - | ||
76 | - def test_exact_case | ||
77 | - store_names ["Hello"] | ||
78 | - assert_search "hello", [], fields: [{name: :exact}] | ||
79 | - assert_search "Hello", ["Hello"], fields: [{name: :exact}] | ||
80 | - end | ||
81 | -end |
@@ -0,0 +1,81 @@ | @@ -0,0 +1,81 @@ | ||
1 | +require_relative "test_helper" | ||
2 | + | ||
3 | +class PartialMatchTest < Minitest::Test | ||
4 | + def test_autocomplete | ||
5 | + store_names ["Hummus"] | ||
6 | + assert_search "hum", ["Hummus"], match: :text_start | ||
7 | + end | ||
8 | + | ||
9 | + def test_autocomplete_two_words | ||
10 | + store_names ["Organic Hummus"] | ||
11 | + assert_search "hum", [], match: :text_start | ||
12 | + end | ||
13 | + | ||
14 | + def test_autocomplete_fields | ||
15 | + store_names ["Hummus"] | ||
16 | + assert_search "hum", ["Hummus"], match: :text_start, fields: [:name] | ||
17 | + end | ||
18 | + | ||
19 | + def test_text_start | ||
20 | + store_names ["Where in the World is Carmen San Diego"] | ||
21 | + assert_search "where in the world is", ["Where in the World is Carmen San Diego"], fields: [{name: :text_start}] | ||
22 | + assert_search "in the world", [], fields: [{name: :text_start}] | ||
23 | + end | ||
24 | + | ||
25 | + def test_text_middle | ||
26 | + store_names ["Where in the World is Carmen San Diego"] | ||
27 | + assert_search "where in the world is", ["Where in the World is Carmen San Diego"], fields: [{name: :text_middle}] | ||
28 | + assert_search "n the wor", ["Where in the World is Carmen San Diego"], fields: [{name: :text_middle}] | ||
29 | + assert_search "men san diego", ["Where in the World is Carmen San Diego"], fields: [{name: :text_middle}] | ||
30 | + assert_search "world carmen", [], fields: [{name: :text_middle}] | ||
31 | + end | ||
32 | + | ||
33 | + def test_text_end | ||
34 | + store_names ["Where in the World is Carmen San Diego"] | ||
35 | + assert_search "men san diego", ["Where in the World is Carmen San Diego"], fields: [{name: :text_end}] | ||
36 | + assert_search "carmen san", [], fields: [{name: :text_end}] | ||
37 | + end | ||
38 | + | ||
39 | + def test_word_start | ||
40 | + store_names ["Where in the World is Carmen San Diego"] | ||
41 | + assert_search "car san wor", ["Where in the World is Carmen San Diego"], fields: [{name: :word_start}] | ||
42 | + end | ||
43 | + | ||
44 | + def test_word_middle | ||
45 | + store_names ["Where in the World is Carmen San Diego"] | ||
46 | + assert_search "orl", ["Where in the World is Carmen San Diego"], fields: [{name: :word_middle}] | ||
47 | + end | ||
48 | + | ||
49 | + def test_word_end | ||
50 | + store_names ["Where in the World is Carmen San Diego"] | ||
51 | + assert_search "rld men ego", ["Where in the World is Carmen San Diego"], fields: [{name: :word_end}] | ||
52 | + end | ||
53 | + | ||
54 | + def test_word_start_multiple_words | ||
55 | + store_names ["Dark Grey", "Dark Blue"] | ||
56 | + assert_search "dark grey", ["Dark Grey"], fields: [{name: :word_start}] | ||
57 | + end | ||
58 | + | ||
59 | + def test_word_start_exact | ||
60 | + store_names ["Back Scratcher", "Backpack"] | ||
61 | + assert_order "back", ["Back Scratcher", "Backpack"], fields: [{name: :word_start}] | ||
62 | + end | ||
63 | + | ||
64 | + def test_word_start_exact_martin | ||
65 | + store_names ["Martina", "Martin"] | ||
66 | + assert_order "martin", ["Martin", "Martina"], fields: [{name: :word_start}] | ||
67 | + end | ||
68 | + | ||
69 | + # TODO find a better place | ||
70 | + | ||
71 | + def test_exact | ||
72 | + store_names ["hi@example.org"] | ||
73 | + assert_search "hi@example.org", ["hi@example.org"], fields: [{name: :exact}] | ||
74 | + end | ||
75 | + | ||
76 | + def test_exact_case | ||
77 | + store_names ["Hello"] | ||
78 | + assert_search "hello", [], fields: [{name: :exact}] | ||
79 | + assert_search "Hello", ["Hello"], fields: [{name: :exact}] | ||
80 | + end | ||
81 | +end |