text search
This commit is contained in:
@@ -102,3 +102,29 @@ func TestFoldAndTightenSeparators(t *testing.T) {
|
||||
t.Fatalf("tighten: got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
// Lens reads the wrapper as well as the product. No catalogue name carries
|
||||
// "bottle" or "pack", so requiring them found no Dettol at all.
|
||||
func TestSearchTokensDropsPackagingWords(t *testing.T) {
|
||||
for _, tc := range []struct {
|
||||
label string
|
||||
want []string
|
||||
}{
|
||||
{"Dettol bottle pack", []string{"dettol"}},
|
||||
{"Parle G biscuit pack", []string{"parle", "g", "biscuit"}},
|
||||
{"Milk Bikis pack", []string{"milk", "bikis"}},
|
||||
{"Nescafe jar 50g", []string{"nescafe"}},
|
||||
{"pack", []string{"pack"}}, // nothing else: the wrapper is the search
|
||||
{"combo pack", []string{"combo", "pack"}}, // ditto, both kept
|
||||
} {
|
||||
got := SearchTokens(tc.label)
|
||||
if len(got) != len(tc.want) {
|
||||
t.Fatalf("%q: got %v want %v", tc.label, got, tc.want)
|
||||
}
|
||||
for i := range tc.want {
|
||||
if got[i] != tc.want[i] {
|
||||
t.Fatalf("%q: got %v want %v", tc.label, got, tc.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user