My space on the web https://inhji.de
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

76 lines
2.3 KiB

defmodule MirageWeb.LinkLiveTest do
use MirageWeb.ConnCase
import Phoenix.LiveViewTest
import Mirage.LinkFixtures
import Mirage.NoteFixtures
@update_attrs %{title: "some updated title", url: "some updated url"}
@invalid_attrs %{title: nil, url: nil}
describe "Index" do
setup [:create_link, :create_note]
test "lists all notes_links", %{conn: conn, link: link} do
{:ok, _index_live, html} = live(conn, Routes.link_index_path(conn, :index))
assert html =~ "Listing Notes links"
assert html =~ link.title
end
test "updates link in listing", %{conn: conn, link: link} do
{:ok, show_live, _html} = live(conn, Routes.link_show_path(conn, :show, link))
assert show_live |> element("a", "Edit") |> render_click() =~
"Edit Note link"
assert_patch(show_live, Routes.link_show_path(conn, :edit, link))
assert show_live
|> form("#link-form", link: @invalid_attrs)
|> render_change() =~ "can't be blank"
{:ok, _, html} =
show_live
|> form("#link-form", link: @update_attrs)
|> render_submit()
|> follow_redirect(conn, Routes.link_show_path(conn, :show, link))
assert html =~ "Note link updated successfully"
assert html =~ "some updated title"
end
end
describe "Show" do
setup [:create_link]
test "displays link", %{conn: conn, link: link} do
{:ok, _show_live, html} = live(conn, Routes.link_show_path(conn, :show, link))
assert html =~ "Show Note link"
assert html =~ link.title
end
test "updates link within modal", %{conn: conn, link: link} do
{:ok, show_live, _html} = live(conn, Routes.link_show_path(conn, :show, link))
assert show_live |> element("a", "Edit") |> render_click() =~
"Edit Note link"
assert_patch(show_live, Routes.link_show_path(conn, :edit, link))
assert show_live
|> form("#link-form", link: @invalid_attrs)
|> render_change() =~ "can't be blank"
{:ok, _, html} =
show_live
|> form("#link-form", link: @update_attrs)
|> render_submit()
|> follow_redirect(conn, Routes.link_show_path(conn, :show, link))
assert html =~ "Note link updated successfully"
assert html =~ "some updated title"
end
end
end