text search

This commit is contained in:
2026-09-16 12:17:39 +05:30
parent 28af3e05f2
commit c06b029cb2
5 changed files with 133 additions and 11 deletions

View File

@@ -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)
}
}
}
}