defmodule MyAppWeb.BookLiveTest do
use MyAppWeb.ConnCase
import Phoenix.LiveViewTest
describe "with existing books" do
setup %{conn: conn} do
result = register_and_log_in_user(%{conn: conn})
book = book_fixture(result[:user], %{name: "Test Book"})
%{
conn: result[:conn],
user: result[:user],
book: book
}
end
test "lists all books", %{conn: conn, book: book} do
{:ok, _index_live, html} = live(conn, ~p"/books")
assert html =~ "Listing Books"
assert html =~ book.name
end
end
end
defmodule MyAppWeb.BookLiveTest do
use MyAppWeb.ConnCase
import Phoenix.LiveViewTest
describe "with existing books" do
setup %{conn: conn} do
result = register_and_log_in_user(%{conn: conn})
book = book_fixture(result[:user], %{name: "Test Book"})
%{
conn: result[:conn],
user: result[:user],
book: book
}
end
test "lists all books", %{conn: conn, book: book} do
{:ok, _index_live, html} = live(conn, ~p"/books")
assert html =~ "Listing Books"
assert html =~ book.name
end
end
end