After "mix phx.gen.live Biddings Bidding biddings bidding_round:integer amount:integer depot_wish_one:string depot_wish_two:string".
This commit is contained in:
125
test/beet_round_server_web/live/bidding_live_test.exs
Normal file
125
test/beet_round_server_web/live/bidding_live_test.exs
Normal file
@ -0,0 +1,125 @@
|
||||
defmodule BeetRoundServerWeb.BiddingLiveTest do
|
||||
use BeetRoundServerWeb.ConnCase
|
||||
|
||||
import Phoenix.LiveViewTest
|
||||
import BeetRoundServer.BiddingsFixtures
|
||||
|
||||
@create_attrs %{amount: 42, bidding_round: 42, depot_wish_one: "some depot_wish_one", depot_wish_two: "some depot_wish_two"}
|
||||
@update_attrs %{amount: 43, bidding_round: 43, depot_wish_one: "some updated depot_wish_one", depot_wish_two: "some updated depot_wish_two"}
|
||||
@invalid_attrs %{amount: nil, bidding_round: nil, depot_wish_one: nil, depot_wish_two: nil}
|
||||
|
||||
setup :register_and_log_in_user
|
||||
|
||||
defp create_bidding(%{scope: scope}) do
|
||||
bidding = bidding_fixture(scope)
|
||||
|
||||
%{bidding: bidding}
|
||||
end
|
||||
|
||||
describe "Index" do
|
||||
setup [:create_bidding]
|
||||
|
||||
test "lists all biddings", %{conn: conn, bidding: bidding} do
|
||||
{:ok, _index_live, html} = live(conn, ~p"/biddings")
|
||||
|
||||
assert html =~ "Listing Biddings"
|
||||
assert html =~ bidding.depot_wish_one
|
||||
end
|
||||
|
||||
test "saves new bidding", %{conn: conn} do
|
||||
{:ok, index_live, _html} = live(conn, ~p"/biddings")
|
||||
|
||||
assert {:ok, form_live, _} =
|
||||
index_live
|
||||
|> element("a", "New Bidding")
|
||||
|> render_click()
|
||||
|> follow_redirect(conn, ~p"/biddings/new")
|
||||
|
||||
assert render(form_live) =~ "New Bidding"
|
||||
|
||||
assert form_live
|
||||
|> form("#bidding-form", bidding: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|
||||
assert {:ok, index_live, _html} =
|
||||
form_live
|
||||
|> form("#bidding-form", bidding: @create_attrs)
|
||||
|> render_submit()
|
||||
|> follow_redirect(conn, ~p"/biddings")
|
||||
|
||||
html = render(index_live)
|
||||
assert html =~ "Bidding created successfully"
|
||||
assert html =~ "some depot_wish_one"
|
||||
end
|
||||
|
||||
test "updates bidding in listing", %{conn: conn, bidding: bidding} do
|
||||
{:ok, index_live, _html} = live(conn, ~p"/biddings")
|
||||
|
||||
assert {:ok, form_live, _html} =
|
||||
index_live
|
||||
|> element("#biddings-#{bidding.id} a", "Edit")
|
||||
|> render_click()
|
||||
|> follow_redirect(conn, ~p"/biddings/#{bidding}/edit")
|
||||
|
||||
assert render(form_live) =~ "Edit Bidding"
|
||||
|
||||
assert form_live
|
||||
|> form("#bidding-form", bidding: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|
||||
assert {:ok, index_live, _html} =
|
||||
form_live
|
||||
|> form("#bidding-form", bidding: @update_attrs)
|
||||
|> render_submit()
|
||||
|> follow_redirect(conn, ~p"/biddings")
|
||||
|
||||
html = render(index_live)
|
||||
assert html =~ "Bidding updated successfully"
|
||||
assert html =~ "some updated depot_wish_one"
|
||||
end
|
||||
|
||||
test "deletes bidding in listing", %{conn: conn, bidding: bidding} do
|
||||
{:ok, index_live, _html} = live(conn, ~p"/biddings")
|
||||
|
||||
assert index_live |> element("#biddings-#{bidding.id} a", "Delete") |> render_click()
|
||||
refute has_element?(index_live, "#biddings-#{bidding.id}")
|
||||
end
|
||||
end
|
||||
|
||||
describe "Show" do
|
||||
setup [:create_bidding]
|
||||
|
||||
test "displays bidding", %{conn: conn, bidding: bidding} do
|
||||
{:ok, _show_live, html} = live(conn, ~p"/biddings/#{bidding}")
|
||||
|
||||
assert html =~ "Show Bidding"
|
||||
assert html =~ bidding.depot_wish_one
|
||||
end
|
||||
|
||||
test "updates bidding and returns to show", %{conn: conn, bidding: bidding} do
|
||||
{:ok, show_live, _html} = live(conn, ~p"/biddings/#{bidding}")
|
||||
|
||||
assert {:ok, form_live, _} =
|
||||
show_live
|
||||
|> element("a", "Edit")
|
||||
|> render_click()
|
||||
|> follow_redirect(conn, ~p"/biddings/#{bidding}/edit?return_to=show")
|
||||
|
||||
assert render(form_live) =~ "Edit Bidding"
|
||||
|
||||
assert form_live
|
||||
|> form("#bidding-form", bidding: @invalid_attrs)
|
||||
|> render_change() =~ "can't be blank"
|
||||
|
||||
assert {:ok, show_live, _html} =
|
||||
form_live
|
||||
|> form("#bidding-form", bidding: @update_attrs)
|
||||
|> render_submit()
|
||||
|> follow_redirect(conn, ~p"/biddings/#{bidding}")
|
||||
|
||||
html = render(show_live)
|
||||
assert html =~ "Bidding updated successfully"
|
||||
assert html =~ "some updated depot_wish_one"
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user