Skip to content

Commit 83a4a31

Browse files
committed
Improve test for suggestion search
* Match on the `Snap.Suggest` and `Snap.Suggest.Option` structs * Match additional `freq` and `score` fields * Assert that `score` is a float
1 parent 5e31725 commit 83a4a31

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

test/search_test.exs

+10-1
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,17 @@ defmodule Snap.SearchTest do
5454
assert first_hit.source["title"] == "Document 1"
5555

5656
assert %Snap.SearchResponse{
57-
suggest: %{"title" => [%{text: "doument", options: [%{text: "document"}]}]}
57+
suggest: %{
58+
"title" => [
59+
%Snap.Suggest{
60+
text: "doument",
61+
options: [%Snap.Suggest.Option{freq: 5, text: "document", score: score}]
62+
}
63+
]
64+
}
5865
} = search_response
66+
67+
assert is_float(score)
5968
end
6069

6170
test "count/2 without a query" do

0 commit comments

Comments
 (0)