Apply Testing LiveView course patterns (live/2, has_element?, render_click, form/3). Add tests for MobileQRLive, WeathermapLive, StatusPageLive, controllers, plugs, and pure function modules. Expand proto decode coverage to 85.24%.
28 lines
786 B
Elixir
28 lines
786 B
Elixir
defmodule ToweropsWeb.Plugs.DetectEUUserTest do
|
|
use ToweropsWeb.ConnCase, async: true
|
|
|
|
alias ToweropsWeb.Plugs.DetectEUUser
|
|
|
|
describe "call/2" do
|
|
test "requires cookie consent on localhost", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> init_test_session(%{})
|
|
|> Map.put(:host, "localhost")
|
|
|> DetectEUUser.call([])
|
|
|
|
assert conn.assigns.requires_cookie_consent == true
|
|
end
|
|
|
|
test "does not require consent when consent cookie is present", %{conn: conn} do
|
|
conn =
|
|
conn
|
|
|> init_test_session(%{})
|
|
|> Map.put(:host, "localhost")
|
|
|> Plug.Conn.put_req_header("cookie", "cookie_consent=accepted")
|
|
|> DetectEUUser.call([])
|
|
|
|
assert conn.assigns.requires_cookie_consent == false
|
|
end
|
|
end
|
|
end
|