Fix events test for new search signature

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2020-08-04 09:24:09 +02:00
parent 2198b2cb87
commit d725393fd4
No known key found for this signature in database
GPG Key ID: A061B9DDE0CA0773

View File

@ -60,16 +60,18 @@ defmodule Mobilizon.EventsTest do
test "build_events_for_search/1 returns events for a given name", %{ test "build_events_for_search/1 returns events for a given name", %{
event: %Event{title: title} = event event: %Event{title: title} = event
} do } do
assert title == hd(Events.build_events_for_search(event.title).elements).title assert title == hd(Events.build_events_for_search(%{term: event.title}).elements).title
%Event{} = event2 = insert(:event, title: "Special event") %Event{} = event2 = insert(:event, title: "Special event")
Workers.BuildSearch.insert_search_event(event2) Workers.BuildSearch.insert_search_event(event2)
assert event2.title == assert event2.title ==
Events.build_events_for_search("Special").elements |> hd() |> Map.get(:title) Events.build_events_for_search(%{term: "Special"}).elements
|> hd()
|> Map.get(:title)
assert event2.title == assert event2.title ==
Events.build_events_for_search(" Spécïal ").elements Events.build_events_for_search(%{term: " Spécïal "}).elements
|> hd() |> hd()
|> Map.get(:title) |> Map.get(:title)
@ -79,9 +81,9 @@ defmodule Mobilizon.EventsTest do
Workers.BuildSearch.insert_search_event(event3) Workers.BuildSearch.insert_search_event(event3)
assert event3.title == assert event3.title ==
Events.build_events_for_search("hola").elements |> hd() |> Map.get(:title) Events.build_events_for_search(%{term: "hola"}).elements |> hd() |> Map.get(:title)
assert %Page{elements: [], total: 0} == Events.build_events_for_search("") assert %Page{elements: _elements, total: 3} = Events.build_events_for_search(%{term: ""})
end end
test "find_close_events/3 returns events in the area" do test "find_close_events/3 returns events in the area" do