defmodule AprsmeWeb.ErrorHTMLTest do
  use AprsmeWeb.ConnCase

  # Bring render_to_string/3 for testing custom views
  import Phoenix.Template

  test "renders 404.html" do
    assert render_to_string(AprsmeWeb.ErrorHTML, "404", "html", []) == "Not Found"
  end

  test "renders 500.html" do
    assert render_to_string(AprsmeWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
  end

  test "renders explicit 'Bad Request' for 400.html" do
    assert AprsmeWeb.ErrorHTML.render("400.html", %{}) == "Bad Request"
  end

  test "delegates 403/401 to Phoenix default template messages" do
    assert AprsmeWeb.ErrorHTML.render("403.html", %{}) == "Forbidden"
    assert AprsmeWeb.ErrorHTML.render("401.html", %{}) == "Unauthorized"
  end

  test "unknown template falls through to the delegated default" do
    assert String.length(AprsmeWeb.ErrorHTML.render("999.html", %{})) > 0
  end
end
