Files
firehose/app/test/firehose_web/controllers/page_controller_test.exs
T

44 lines
1.3 KiB
Elixir

defmodule FirehoseWeb.PageControllerTest do
use FirehoseWeb.ConnCase
describe "GET /" do
test "renders the homepage", %{conn: conn} do
body = conn |> get(~p"/") |> html_response(200)
assert body =~ "Drinking from the firehose"
assert body =~ "Willem van den Ende"
end
test "shows navigation links", %{conn: conn} do
body = conn |> get(~p"/") |> html_response(200)
assert body =~ ~s|/blog/engineering|
assert body =~ ~s|/blog/releases|
assert body =~ ~s|/contact|
end
test "does not show dashboard link when unauthenticated", %{conn: conn} do
body = conn |> get(~p"/") |> html_response(200)
refute body =~ ~s|/editor/dashboard|
end
end
describe "GET /contact" do
test "renders the contact page inside the app layout", %{conn: conn} do
body = conn |> get(~p"/contact") |> html_response(200)
# Page content (contact.html.heex) ...
assert body =~ "Get in touch"
# ... wrapped by the app layout, which is where the site nav lives.
assert body =~ ~s|/blog/engineering|
end
end
describe "GET / when authenticated" do
setup :register_and_log_in_user
test "shows dashboard link in navigation", %{conn: conn} do
body = conn |> get(~p"/") |> html_response(200)
assert body =~ ~s|/editor/dashboard|
end
end
end