defmodule WishWeb.HomeLiveTest do
  use WishWeb.ConnCase

  import Phoenix.LiveViewTest
  import Wish.WishlistFixtures
  import Wish.AccountsFixtures

  defp create_item(_) do
    item = item_fixture()
    %{item: item}
  end

  describe "Index" do
    setup [:create_item]

    test "lists all items", %{conn: conn, item: item} do
      {:ok, _index_live, html} =
        conn
        |> log_in_user(user_fixture())
        |> live(~p"/")

      assert html =~ "Daniel&#39;s Wishlist"
      assert html =~ item.description
    end
  end
end
