33 lines
910 B
Elixir
33 lines
910 B
Elixir
defmodule MvWeb.Components.SearchBarComponentTest do
|
|
use MvWeb.ConnCase, async: true
|
|
import Phoenix.LiveViewTest
|
|
|
|
describe "SearchBarComponent" do
|
|
test "renders with placeholder", %{conn: conn} do
|
|
conn = conn_with_oidc_user(conn)
|
|
{:ok, view, _html} = live(conn, "/members")
|
|
|
|
assert has_element?(view, "input[placeholder='Search...']")
|
|
end
|
|
|
|
test "updates query when user types", %{conn: conn} do
|
|
conn = conn_with_oidc_user(conn)
|
|
{:ok, view, _html} = live(conn, "/members")
|
|
|
|
# simulate search input and check that other members are not listed
|
|
html =
|
|
view
|
|
|> element("form[role=search]")
|
|
|> render_change(%{"query" => "Friedrich"})
|
|
|
|
refute html =~ "Greta"
|
|
|
|
html =
|
|
view
|
|
|> element("form[role=search]")
|
|
|> render_change(%{"query" => "Greta"})
|
|
|
|
refute html =~ "Friedrich"
|
|
end
|
|
end
|
|
end
|